| | |
| | | |
| | | #include <guiddef.h> |
| | | #include <exdisp.h> // Defines of stuff like IWebBrowser2. This is an include file with Visual C 6 and above |
| | | #include <mshtml.h> // Defines of stuff like IHTMLDocument2. This is an include file with Visual C 6 and above |
| | | #include <mshtmhst.h> // Defines of stuff like IDocHostUIHandler. This is an include file with Visual C 6 and above |
| | | #include <Shlwapi.h> |
| | | #include <Windows.h> |
| | | #include <comutil.h> |
| | | |
| | | #undef _XWIN |
| | | |
| | | #include <wobject/xstring.hpp> |
| | | #include <xcontrol/xtreeview.hpp> |
| | | #include <xcontrol/xdwgrid.hpp> |
| | | #include <xcontrol/xlayersheet.hpp> |
| | | #include <xcontrol/xhtml.hpp> |
| | | #include <wobject/xutil.hpp> |
| | | |
| | | #include "vbusiness/vframe/maint.vframe.vbusiness.hpp" |
| | | #include "viewobject/view.base.hpp" |
| | | #include <xcontrol/xcell.hpp> |
| | | #include <xcontrol/xexcel.hpp> |
| | | #include <xcontrol/xhtml.hpp> |
| | | #include <win32/xfile.hpp> |
| | | |
| | | using xml = KXMLDOMDocument; |
| | | |
| | | #if 0 |
| | | namespace _excel for ole "Excel.Application,{00020813-0000-0000-C000-000000000046}"; |
| | | namespace _mshtml for ole "MSHtml,{3050F1C5-98B5-11CF-BB82-00AA00BDCE0B}"; |
| | | |
| | |
| | | static int CreateInstance() alias "?CreateInstance@CExcelApplication@@SAPAV1@XZ"; |
| | | void put_Visible(bool t) alias "?put_Visible@CExcelApplication@@QAEXH@Z"; |
| | | bool get_Visible() alias "?get_Visible@CExcelApplication@@QAEHXZ"; |
| | | void OpenDocument(const string filename) alias "?OpenDocument@CExcelApplication@@QAEXQA_W@Z"; |
| | | void OpenDocument(const xstring filename) alias "?OpenDocument@CExcelApplication@@QAEXQA_W@Z"; |
| | | void TransShape() alias "?TransShape@CExcelApplication@@QAEXXZ"; |
| | | void SaveToFile(string filename) alias "?SaveToFile@CExcelApplication@@QAEXQA_W@Z"; |
| | | void SaveToFile(xstring filename) alias "?SaveToFile@CExcelApplication@@QAEXQA_W@Z"; |
| | | void Quit() alias "?Quit@CExcelApplication@@QAEXXZ"; |
| | | }; |
| | | |
| | | struct MYOPENFILENAMEW |
| | | { |
| | | unsigned int lStructSize; |
| | | unsigned int hwndOwner; |
| | | unsigned int hInstance; |
| | | string lpstrFilter; |
| | | |
| | | string lpstrCustomFilter; |
| | | unsigned int nMaxCustFilter; |
| | | unsigned int nFilterIndex; |
| | | string lpstrFile; |
| | | |
| | | unsigned int nMaxFile; |
| | | string lpstrFileTitle; |
| | | unsigned int nMaxFileTitle; |
| | | string lpstrInitialDir; |
| | | |
| | | string lpstrTitle; |
| | | unsigned int Flags; |
| | | unsigned short nFileOffset; |
| | | unsigned short nFileExtension; |
| | | string lpstrDefExt; |
| | | |
| | | unsigned int lCustData; |
| | | unsigned int lpfnHook; |
| | | string lpTemplateName; |
| | | |
| | | //_WIN32_WINNT >= 0x0500 |
| | | unsigned int pvReserved; |
| | | unsigned int dwReserved; |
| | | unsigned int FlagsEx; |
| | | // (_WIN32_WINNT >= 0x0500) |
| | | }; |
| | | #endif |
| | | |
| | | class TemplatePrintViewEx : public frame |
| | | DeclWinObject_(TemplatePrintViewEx, xframe) |
| | | { |
| | | xole ole_print; |
| | | CreateWinObject_(TemplatePrintViewEx, xframe) |
| | | public: |
| | | xhtml ole_print; |
| | | xcell cell; |
| | | string m_EntityName; |
| | | string m_EntityID; |
| | | string m_EntityNo; |
| | | string m_strHtml; |
| | | string m_spath; |
| | | xstring m_SupplierName; |
| | | xstring m_EntityName; |
| | | xstring m_EntityID; |
| | | xstring m_EntityNo; |
| | | xstring m_strHtml; |
| | | xstring m_spath; |
| | | bool updated; |
| | | |
| | | string htmlStr; |
| | | cexcel excel; |
| | | xstring htmlStr; |
| | | bool editing; |
| | | |
| | | string billName ; |
| | | string billID ; |
| | | string billPre; |
| | | xstring billName ; |
| | | xstring billID ; |
| | | xstring billPre; |
| | | |
| | | string m_DocumentID; |
| | | xstring m_DocumentID; |
| | | xml m_dataset; |
| | | //bool showgrid; |
| | | bool PaperPrint; |
| | | |
| | | static stdcall int GetModuleFileName(int hModule ,string lpFileName ,int nSize ) native from "kernel32.dll" alias "GetModuleFileNameW"; |
| | | static stdcall int PathRemoveFileSpec(string lpFileName ) native from "shlwapi.dll" alias "PathRemoveFileSpecW"; |
| | | static stdcall int DeleteFile(string lpFileName) native from "kernel32.dll" alias "DeleteFileW"; |
| | | #if 0 |
| | | cexcel excel; |
| | | static stdcall int GetModuleFileName(int hModule ,xstring lpFileName ,int nSize ) native from "kernel32.dll" alias "GetModuleFileNameW"; |
| | | static stdcall int PathRemoveFileSpec(xstring lpFileName ) native from "shlwapi.dll" alias "PathRemoveFileSpecW"; |
| | | static stdcall int DeleteFile(xstring lpFileName) native from "kernel32.dll" alias "DeleteFileW"; |
| | | static stdcall bool GetSaveFileName(ref MYOPENFILENAMEW)native from "comdlg32.dll" alias "GetSaveFileNameW"; |
| | | #endif |
| | | |
| | | string GetModulePath() |
| | | |
| | | xstring GetMySaveFileName(xstring initFileName, xstring filter, xstring ext) |
| | | { |
| | | string str =""; |
| | | str = str.space(255); |
| | | GetModuleFileName(0,str,250); |
| | | PathRemoveFileSpec(str); |
| | | return str; |
| | | } |
| | | string GetModuleTmpPath() |
| | | { |
| | | string str =""; |
| | | str = str.space(255); |
| | | GetModuleFileName(0,str,250); |
| | | PathRemoveFileSpec(str); |
| | | string tmp = str + "\\Temp"; |
| | | xaserver::CreateDirectory(tmp); |
| | | return tmp; |
| | | } |
| | | |
| | | string GetSaveFileName(string initFileName, string filter, string ext) |
| | | { |
| | | char[] szFileName = new char[255] ; |
| | | char[] szPath = new char[255]; |
| | | szFileName[0] = 0; |
| | | szPath[0] = 0; |
| | | wchar_t szFileName[255] = { 0 }; |
| | | wchar_t szPath[255] = { 0 }; |
| | | |
| | | if(initFileName !="") |
| | | if(initFileName !=L"") |
| | | { |
| | | int len = initFileName.length(); |
| | | char[] tmp = initFileName; |
| | | const wchar_t* tmp = initFileName; |
| | | for(int i=0; i<len+1;i++) |
| | | { |
| | | //szFileName[i] = tmp[i]; |
| | |
| | | } |
| | | |
| | | int nFilterIndex = 1; |
| | | ref MYOPENFILENAMEW ofn = new MYOPENFILENAMEW; |
| | | |
| | | ofn.lStructSize = 88;//sizeof(ofn); |
| | | ofn.hwndOwner = 0; |
| | | OPENFILENAMEW ofn = { 0 }; |
| | | //::ZeroMemory(&ofn,sizeof(OPENFILENAMEW)) |
| | | //ofn.lStructSize = 88;//sizeof(ofn); |
| | | ofn.lStructSize = sizeof(ofn); |
| | | ofn.hwndOwner = GetHWND(); |
| | | ofn.hInstance = 0; |
| | | ofn.lpstrFilter = filter; |
| | | //"JPEG 文件(*.jpg)\0*.jpg;*.jpeg;*.png;*.gif;*.bmp\0全部文件(*.*)\0*.*\0"; |
| | |
| | | ofn.nMaxFile = 255; |
| | | ofn.lpstrFileTitle = szFileName; |
| | | ofn.nMaxFileTitle = 255; |
| | | ofn.lpstrTitle = "请指定文件名"; |
| | | ofn.lpstrTitle = L"请指定文件名"; |
| | | ofn.lpstrDefExt = ext; |
| | | //"jpg"; |
| | | ofn.lpstrInitialDir = 0; |
| | |
| | | ofn.lpTemplateName = 0; |
| | | |
| | | //debugbreak(); |
| | | if(GetSaveFileName(ofn)) |
| | | if(xfile::GetSaveFileNameW(ofn)) |
| | | { |
| | | delete ofn; |
| | | return szPath; |
| | | } |
| | | else |
| | | { |
| | | return ""; |
| | | return L""; |
| | | } |
| | | } |
| | | |
| | | int OnExport() |
| | | { |
| | | string pre = billPre; |
| | | if(pre=="") |
| | | xstring pre = billPre; |
| | | if(pre==L"") |
| | | { |
| | | pre = m_EntityName; |
| | | if(m_EntityName=="SaleOrder") pre="PI"; |
| | | if(m_EntityName=="GDN3")pre="INV"; |
| | | if(m_EntityName==L"SaleOrder") pre=L"PI"; |
| | | if(m_EntityName==L"GDN3")pre=L"INV"; |
| | | } |
| | | string file1 = GetSaveFileName(pre+m_EntityNo+".xlsx", |
| | | "Excel1文件(*.xlsx)\0*.xlsx;*.xls\0Excel97文件(*.xls)\0*.xls\0PDF文件(*.pdf)\0*.pdf\0", |
| | | "xlsx"); |
| | | if(file1 =="") return 1; |
| | | if (m_EntityName == L"VATNotify")m_EntityNo = m_EntityNo + m_SupplierName; |
| | | xstring file1 = GetMySaveFileName(pre+m_EntityNo+L".xlsx", |
| | | L"Excel1文件(*.xlsx)\0*.xlsx;*.xls\0Excel97文件(*.xls)\0*.xls\0PDF文件(*.pdf)\0*.pdf\0", |
| | | L"xlsx"); |
| | | if(file1 ==L"") return 1; |
| | | |
| | | if(win32::PathFileExists(file1)) |
| | | if(PathFileExists(file1)) |
| | | { |
| | | int res = win32::MessageBox(this.GetHWND(), "文件已经存在,是否覆盖?","提示",4); |
| | | int res = MessageBox(GetHWND(), L"文件已经存在,是否覆盖?",L"提示",4); |
| | | if(res != 6) return 1; |
| | | } |
| | | |
| | | trace("\r\n link excel"); |
| | | excel = new cexcel; |
| | | int hexcel = cexcel::CreateInstance(); |
| | | excel.setNativePointer(hexcel); |
| | | if(hexcel == 0) |
| | | trace(L"\r\n link excel"); |
| | | xexcel excel; |
| | | if(!excel.GetNativePtr()) |
| | | { |
| | | alert("不能连接Excel"); |
| | | alert(L"不能连接Excel"); |
| | | return 1; |
| | | } |
| | | |
| | | string gid = publiccode::GetGuid(); |
| | | string filename= pre+m_EntityNo+"_.htm"; |
| | | xutil::SaveToFile(GetModuleTmpPath() + "\\"+ filename, htmlStr,"","",""); |
| | | trace("\r\n excel to open"); |
| | | excel .OpenDocument(GetModuleTmpPath() + "\\"+ filename); |
| | | trace("\r\n trans shape"); |
| | | xstring gid = publiccode::GetGuid(); |
| | | xstring filename= pre+m_EntityNo+L"_.htm"; |
| | | xutil::SaveToFile(xutil::GetModuleTmpPath() + L"\\"+ filename, htmlStr,NULL,NULL); |
| | | trace(L"\r\n excel to open"); |
| | | excel .OpenDocument(xutil::GetModuleTmpPath() + L"\\"+ filename); |
| | | trace(L"\r\n trans shape"); |
| | | //excel .put_Visible(true); |
| | | excel.TransShape(); |
| | | trace("\r\n save to tmp excel file"); |
| | | if(file1.find(".xls")) |
| | | trace(L"\r\n save to tmp excel file"); |
| | | if(file1.find(L".xls")) |
| | | { |
| | | if(win32::PathFileExists(GetModuleTmpPath() + "\\"+ pre+m_EntityNo+"_.xls")) |
| | | DeleteFile(GetModuleTmpPath() + "\\"+ pre+m_EntityNo+"_.xls"); |
| | | excel.SaveToFile(GetModuleTmpPath() + "\\"+ pre+m_EntityNo+"_.xls"); |
| | | //alert(GetModuleTmpPath() + "\\"+ pre+m_EntityNo+"_.xls"); |
| | | if(PathFileExists(xutil::GetModuleTmpPath() + L"\\"+ pre+m_EntityNo+L"_.xls")) |
| | | DeleteFile(xutil::GetModuleTmpPath() + L"\\"+ pre+m_EntityNo+L"_.xls"); |
| | | excel.SaveToFile(xutil::GetModuleTmpPath() + L"\\"+ pre+m_EntityNo+L"_.xls"); |
| | | //alert(GetModuleTmpPath() + L"\\"+ pre+m_EntityNo+L"_.xls"); |
| | | } |
| | | else |
| | | { |
| | | if(win32::PathFileExists(GetModuleTmpPath() + "\\"+ pre+m_EntityNo+"_.xlsx")) |
| | | DeleteFile(GetModuleTmpPath() + "\\"+ pre+m_EntityNo+"_.xlsx"); |
| | | excel.SaveToFile(GetModuleTmpPath() + "\\"+ pre+m_EntityNo+"_.xlsx"); |
| | | if(PathFileExists(xutil::GetModuleTmpPath() + L"\\"+ pre+m_EntityNo+L"_.xlsx")) |
| | | DeleteFile(xutil::GetModuleTmpPath() + L"\\"+ pre+m_EntityNo+L"_.xlsx"); |
| | | excel.SaveToFile(xutil::GetModuleTmpPath() + L"\\"+ pre+m_EntityNo+L"_.xlsx"); |
| | | } |
| | | |
| | | trace("\r\n save to excel file"); |
| | | if(win32::PathFileExists(file1)) //GetModuleTmpPath() + "\\"+ pre+m_EntityNo+"_.xlsx")) |
| | | trace(L"\r\n save to excel file"); |
| | | if(PathFileExists(file1)) //GetModuleTmpPath() + L"\\"+ pre+m_EntityNo+L"_.xlsx")) |
| | | DeleteFile(file1); |
| | | excel.SaveToFile(file1); |
| | | |
| | | excel.Quit(); |
| | | excel.Release(excel.ptr_native_); |
| | | //excel.Release(excel.ptr_native_); |
| | | return 1; |
| | | } |
| | | |
| | | int OntoExcel() //תΪExcel |
| | | { |
| | | excel = new cexcel; |
| | | excel.setNativePointer(cexcel::CreateInstance()); |
| | | |
| | | string gid = publiccode::GetGuid(); |
| | | string pre = m_EntityName; |
| | | if(m_EntityName=="SaleOrder") pre="PI"; |
| | | if(m_EntityName=="GDN3")pre="INV"; |
| | | string filename= pre+m_EntityNo+".htm"; |
| | | string filenameex= pre+m_EntityNo+".xlsx"; |
| | | xutil::SaveToFile(GetModuleTmpPath() + "\\"+ filename, htmlStr,"","",""); |
| | | excel .OpenDocument(GetModuleTmpPath() + "\\"+ filename); |
| | | xexcel excel; |
| | | xstring gid = publiccode::GetGuid(); |
| | | xstring pre = m_EntityName; |
| | | if(m_EntityName==L"SaleOrder") pre=L"PI"; |
| | | if(m_EntityName==L"GDN3")pre=L"INV"; |
| | | xstring filename= pre+m_EntityNo+L".htm"; |
| | | xstring filenameex= pre+m_EntityNo+L".xlsx"; |
| | | xutil::SaveToFile(xutil::GetModuleTmpPath() + L"\\"+ filename, htmlStr,NULL,NULL); |
| | | excel .OpenDocument(xutil::GetModuleTmpPath() + L"\\"+ filename); |
| | | //excel.put_Visible(true); |
| | | excel.TransShape(); |
| | | if(win32::PathFileExists(GetModuleTmpPath() + "\\"+ filenameex)) |
| | | DeleteFile(GetModuleTmpPath() + "\\"+ filenameex); |
| | | excel.SaveToFile(GetModuleTmpPath() + "\\"+ filenameex); |
| | | if(PathFileExists(xutil::GetModuleTmpPath() + L"\\"+ filenameex)) |
| | | DeleteFile(xutil::GetModuleTmpPath() + L"\\"+ filenameex); |
| | | excel.SaveToFile(xutil::GetModuleTmpPath() + L"\\"+ filenameex); |
| | | excel.put_Visible(true); |
| | | |
| | | excel.Release(excel.ptr_native_); |
| | | //excel.Release(excel.ptr_native_); |
| | | return 1; |
| | | } |
| | | |
| | | string getfilePath() |
| | | xstring getfilePath() |
| | | { |
| | | string path=GetModulePath()+"\\resource\\image"; |
| | | string filename="contract.jpg"; |
| | | filename="sign.png"; |
| | | filename="jrj_maersk.png"; |
| | | filename="HomeDecorSign.png"; |
| | | xaserver::DownLoadFile(GetServerUrl(),"/business/rpttemplate/"+filename,"",path+"\\"+filename); |
| | | filename="HomeDecorLogo.jpg"; |
| | | xaserver::DownLoadFile(GetServerUrl(),"/business/rpttemplate/"+filename,"",path+"\\"+filename); |
| | | xstring path= xutil::GetModulePath()+L"\\resource\\image"; |
| | | xstring filename=L"contract.jpg"; |
| | | filename=L"sign.png"; |
| | | filename=L"jrj_maersk.png"; |
| | | filename=L"HomeDecorSign.png"; |
| | | xaserver::DownLoadFile(GetServerUrl(),L"/business/rpttemplate/"+filename,L"",path+L"\\"+filename); |
| | | filename=L"HomeDecorLogo.jpg"; |
| | | xaserver::DownLoadFile(GetServerUrl(),L"/business/rpttemplate/"+filename,L"",path+L"\\"+filename); |
| | | return path; |
| | | } |
| | | |
| | | string replaceInnerElement(string html) |
| | | xstring replaceInnerElement(xstring html) |
| | | { |
| | | string str = html; |
| | | if(str.find("[$element:")<0) return str; |
| | | xstring str = html; |
| | | if(str.find(L"[$element:")<0) return str; |
| | | |
| | | int len = 0; |
| | | int pos = 0; |
| | | int pos1 = 0; |
| | | string pre=""; |
| | | string left=""; |
| | | string right=""; |
| | | string tag=""; |
| | | xstring pre=L""; |
| | | xstring left=L""; |
| | | xstring right=L""; |
| | | xstring tag=L""; |
| | | |
| | | len = "[$element:".length(); |
| | | len = ((xstring)L"[$element:").length(); |
| | | while(true) |
| | | { |
| | | pos = str.find("[$element:"); |
| | | pos = str.find(L"[$element:"); |
| | | if(pos < 0) break; |
| | | left = str.left(pos); |
| | | right = str.mid(pos+ len,999999); |
| | | |
| | | pos1 = right.find("]"); |
| | | pos1 = right.find(L"]"); |
| | | if(pos1>=0) |
| | | { |
| | | tag = right.left(pos1); |
| | | if(tag.right(1)=="$") tag=tag.left(tag.length() - 1); |
| | | pre = pre + left + "<" + tag +">"; |
| | | if(tag.right(1)==L"$") tag=tag.left(tag.length() - 1); |
| | | pre = pre + left + L"<" + tag +L">"; |
| | | str = right.mid(pos1+ 1,999999); |
| | | }else |
| | | { |
| | | pre = pre + left+"<"; |
| | | pre = pre + left+L"<"; |
| | | str = right; |
| | | } |
| | | } |
| | | |
| | | str = pre + str; |
| | | pre = ""; |
| | | len = "[/$element:".length(); |
| | | pre = L""; |
| | | len = ((xstring)L"[/$element:").length(); |
| | | while(true) |
| | | { |
| | | pos = str.find("[/$element:"); |
| | | pos = str.find(L"[/$element:"); |
| | | if(pos < 0) break; |
| | | left = str.left(pos); |
| | | right = str.mid(pos+ len,999999); |
| | | pos1 = right.find("]"); |
| | | pos1 = right.find(L"]"); |
| | | if(pos1>=0) |
| | | { |
| | | tag = right.left(pos1); |
| | | if(tag.right(1)=="$") tag=tag.left(tag.length() - 1); |
| | | pre = pre + left + "</" + tag +">"; |
| | | if(tag.right(1)==L"$") tag=tag.left(tag.length() - 1); |
| | | pre = pre + left + L"</" + tag +L">"; |
| | | str = right.mid(pos1+ 1,999999); |
| | | }else |
| | | { |
| | | pre = pre + left+"</"; |
| | | pre = pre + left+L"</"; |
| | | str = right; |
| | | } |
| | | } |
| | |
| | | return str; |
| | | } |
| | | |
| | | string adjustXsl(string str,string localPath) |
| | | xstring adjustXsl(xstring str,xstring localPath) |
| | | { |
| | | //if(str.find("%")>=0) str = str.replace("%",""); |
| | | if(str.find("[$path]/rpttemplate")>=0) str = str.replace("[$path]/rpttemplate",localPath); |
| | | //if(str.find(L"%")>=0) str = str.replace(L"%",L""); |
| | | if(str.find(L"[$path]/rpttemplate")>=0) str = str.replace(L"[$path]/rpttemplate",localPath); |
| | | str = replaceInnerElement(str); |
| | | return str; |
| | | } |
| | | |
| | | string DownLoadSKUNoPic(string SKUNo,string CustomerID="",string CustomerItemNo="") |
| | | #if 0 |
| | | xstring DownLoadSKUNoPic(xstring SKUNo,xstring CustomerID=L"",xstring CustomerItemNo=L"") |
| | | { |
| | | |
| | | if(SKUNo.length()>20) return DownLoadPaperPic(SKUNo); |
| | | |
| | | xml x = new xml; |
| | | x.setNativePointer(xml::CreateInstance()); |
| | | xaserverarg arg = new xaserverarg; |
| | | arg.setNativePointer(arg.CreateInstance()); |
| | | arg.AddArg("SKUNo",SKUNo); |
| | | xml x; |
| | | |
| | | string src ="/sale/data/ProductLibrary3/pref/picture/imagelistSKUNo"; |
| | | if(CustomerID !="") |
| | | xaserverarg arg; |
| | | |
| | | arg.AddArg(L"SKUNo",SKUNo); |
| | | |
| | | xstring src =L"/sale/data/ProductLibrary3/pref/picture/imagelistSKUNo"; |
| | | if(CustomerID !=L"") |
| | | { |
| | | arg.AddArg("CustomerID",CustomerID); |
| | | arg.AddArg("CustomerItemNo",CustomerItemNo); |
| | | src ="/sale/data/ProductLibrary3/pref/picture/customer/imagelistSKUNo"; |
| | | arg.AddArg(L"CustomerID",CustomerID); |
| | | arg.AddArg(L"CustomerItemNo",CustomerItemNo); |
| | | src =L"/sale/data/ProductLibrary3/pref/picture/customer/imagelistSKUNo"; |
| | | } |
| | | //trace("SKUNo="+SKUNo);//要有展示图片查询条件内必定要skuno |
| | | if(url::get(src,arg.GetString(),x)!=1) |
| | | //trace(L"SKUNo=L"+SKUNo);//要有展示图片查询条件内必定要skuno |
| | | if(xurl::get(src,arg.GetString(),x)!=1) |
| | | { |
| | | trace("error for download skuno pic!"); |
| | | return ""; |
| | | trace(L"error for download skuno pic!"); |
| | | return L""; |
| | | } |
| | | |
| | | string spath = ""; |
| | | string path =GetModuleTmpPath(); |
| | | string ext = "jpg"; |
| | | if(x.GetXmlDoc().selectSingleNode("//FileExt[1]")) |
| | | xstring spath = L""; |
| | | xstring path = xutil::GetModuleTmpPath(); |
| | | xstring ext = L"jpg"; |
| | | if(x.selectSingleNode(L"//FileExt[1]")) |
| | | { |
| | | ext = x.GetXmlDoc().selectSingleNode("//FileExt[1]").text; |
| | | }else if(CustomerID !="") |
| | | ext = x.selectSingleNode(L"//FileExt[1]").text(); |
| | | }else if(CustomerID !=L"") |
| | | { |
| | | src ="/sale/data/ProductLibrary3/pref/picture/imagelistSKUNo"; |
| | | if(url::get(src,arg.GetString(),x)!=1) |
| | | src =L"/sale/data/ProductLibrary3/pref/picture/imagelistSKUNo"; |
| | | if(xurl::get(src,arg.GetString(),x)!=1) |
| | | { |
| | | trace("error for download skuno pic!"); |
| | | return ""; |
| | | trace(L"error for download skuno pic!"); |
| | | return L""; |
| | | } |
| | | if(x.GetXmlDoc().selectSingleNode("//FileExt[1]")) |
| | | ext = x.GetXmlDoc().selectSingleNode("//FileExt[1]").text; |
| | | if(x.selectSingleNode(L"//FileExt[1]")) |
| | | ext = x.selectSingleNode(L"//FileExt[1]").text(); |
| | | } |
| | | |
| | | string filename = SKUNo + "." + ext; |
| | | if(x.GetXmlDoc().selectSingleNode("//PicPath[1]")) |
| | | spath = x.GetXmlDoc().selectSingleNode("//PicPath[1]").text; |
| | | if(spath != "") |
| | | xstring filename = SKUNo + L"." + ext; |
| | | if(x.selectSingleNode(L"//PicPath[1]")) |
| | | spath = x.selectSingleNode(L"//PicPath[1]").text(); |
| | | if(spath != L"") |
| | | { |
| | | xaserver::DownLoadFile(GetServerUrl(),spath,"",path+"/"+filename); |
| | | xaserver::DownLoadFile(GetServerUrl(),spath,L"",path+L"/"+filename); |
| | | } |
| | | return "file://"+ path+"/"+filename; |
| | | return (xstring)L"file://"+ path+L"/"+filename; |
| | | } |
| | | |
| | | string DownLoadSKUNoPic(string SKUNo,string CustomerID="",string CustomerItemNo="") |
| | | #endif |
| | | xstring DownLoadSKUNoPic(xstring SKUNo,xstring CustomerID=L"",xstring CustomerItemNo=L"") |
| | | { |
| | | |
| | | if(SKUNo.length()>20) return DownLoadPaperPic(SKUNo); |
| | | |
| | | xml x = new xml; |
| | | x.setNativePointer(xml::CreateInstance()); |
| | | xaserverarg arg = new xaserverarg; |
| | | arg.setNativePointer(arg.CreateInstance()); |
| | | arg.AddArg("SKUNo",SKUNo); |
| | | xml x; |
| | | xaserverarg arg; |
| | | arg.AddArg(L"SKUNo",SKUNo); |
| | | |
| | | string src ="/sale/data/ProductLibrary3/pref/picture/imagelistSKUNo"; |
| | | if(CustomerID !="") |
| | | xstring src =L"/sale/data/ProductLibrary3/pref/picture/imagelistSKUNo"; |
| | | if(CustomerID !=L"") |
| | | { |
| | | arg.AddArg("CustomerID",CustomerID); |
| | | arg.AddArg("CustomerItemNo",CustomerItemNo); |
| | | src ="/sale/data/ProductLibrary3/pref/picture/customer/imagelistSKUNo"; |
| | | arg.AddArg(L"CustomerID",CustomerID); |
| | | arg.AddArg(L"CustomerItemNo",CustomerItemNo); |
| | | src =L"/sale/data/ProductLibrary3/pref/picture/customer/imagelistSKUNo"; |
| | | } |
| | | //trace("SKUNo="+SKUNo);//要有展示图片查询条件内必定要skuno |
| | | if(url::get(src,arg.GetString(),x)!=1) |
| | | //trace(L"SKUNo=L"+SKUNo);//要有展示图片查询条件内必定要skuno |
| | | if(xurl::get(src,arg.GetString(),x)!=1) |
| | | { |
| | | trace("error for download skuno pic!"); |
| | | return ""; |
| | | trace(L"error for download skuno pic!"); |
| | | return L""; |
| | | } |
| | | |
| | | string spath = ""; |
| | | string path =GetModuleTmpPath(); |
| | | string ext = "jpg"; |
| | | if(x.GetXmlDoc().selectSingleNode("//FileExt[1]")) |
| | | xstring spath = L""; |
| | | xstring path = xutil::GetModuleTmpPath(); |
| | | xstring ext = L"jpg"; |
| | | if(x.selectSingleNode(L"//FileExt[1]")) |
| | | { |
| | | ext = x.GetXmlDoc().selectSingleNode("//FileExt[1]").text; |
| | | }else if(CustomerID !="") |
| | | ext = x.selectSingleNode(L"//FileExt[1]").text(); |
| | | }else if(CustomerID !=L"") |
| | | { |
| | | src ="/sale/data/ProductLibrary3/pref/picture/imagelistSKUNo"; |
| | | if(url::get(src,arg.GetString(),x)!=1) |
| | | src =L"/sale/data/ProductLibrary3/pref/picture/imagelistSKUNo"; |
| | | if(xurl::get(src,arg.GetString(),x)!=1) |
| | | { |
| | | trace("error for download skuno pic!"); |
| | | return ""; |
| | | trace(L"error for download skuno pic!"); |
| | | return L""; |
| | | } |
| | | if(x.GetXmlDoc().selectSingleNode("//FileExt[1]")) |
| | | ext = x.GetXmlDoc().selectSingleNode("//FileExt[1]").text; |
| | | if(x.selectSingleNode(L"//FileExt[1]")) |
| | | ext = x.selectSingleNode(L"//FileExt[1]").text(); |
| | | } |
| | | |
| | | string filename = SKUNo + "." + ext; |
| | | if(x.GetXmlDoc().selectSingleNode("//PicPath[1]")) |
| | | spath = x.GetXmlDoc().selectSingleNode("//PicPath[1]").text; |
| | | if(spath != "") |
| | | xstring filename = SKUNo + L"." + ext; |
| | | if(x.selectSingleNode(L"//PicPath[1]")) |
| | | spath = x.selectSingleNode(L"//PicPath[1]").text(); |
| | | if(spath != L"") |
| | | { |
| | | xaserver::DownLoadFile(GetServerUrl(),spath,"",path+"/"+filename); |
| | | xaserver::DownLoadFile(GetServerUrl(),spath,L"",path+L"/"+filename); |
| | | } |
| | | return "file://"+ path+"/"+filename; |
| | | return L"file://"+ path+L"/"+filename; |
| | | } |
| | | |
| | | string GetImageUrl(string id) |
| | | xstring GetImageUrl(xstring id) |
| | | { |
| | | xml xp=new xml; |
| | | xp.setNativePointer(xml::CreateInstance()); |
| | | xaserverarg arg_pic=new xaserverarg; |
| | | arg_pic.setNativePointer(arg_pic.CreateInstance()); |
| | | arg_pic.AddArg("id",id); |
| | | xml xp; |
| | | xaserverarg arg_pic; |
| | | arg_pic.AddArg(L"id",id); |
| | | |
| | | string res = "/sale/data/productlibrary3/image/url"; |
| | | if(url::get(res,arg_pic.GetString(),xp)!=1) |
| | | xstring res = L"/sale/data/productlibrary3/image/url"; |
| | | if(xurl::get(res,arg_pic.GetString(),xp)!=1) |
| | | { |
| | | xp.GetXml(); |
| | | xp.xml(); |
| | | return 1; |
| | | }else |
| | | { |
| | | string path = xp.GetXmlDoc().text; |
| | | if(path !="") return path; |
| | | xstring path = xp.text(); |
| | | if(path !=L"") return path; |
| | | } |
| | | |
| | | return "/business/products/chanpin/"+id.left(2)+"/"+ id+".jpg"; |
| | | return L"/business/products/chanpin/"+id.left(2)+L"/"+ id+L".jpg"; |
| | | } |
| | | |
| | | string DownLoadPaperPic(string guid) |
| | | xstring DownLoadPaperPic(xstring guid) |
| | | { |
| | | |
| | | string path =GetModuleTmpPath(); |
| | | string ext = "jpg"; |
| | | string filename = guid + "." + ext; |
| | | string spath = GetImageUrl(guid); |
| | | xstring path = xutil::GetModuleTmpPath(); |
| | | xstring ext = L"jpg"; |
| | | xstring filename = guid + L"." + ext; |
| | | xstring spath = GetImageUrl(guid); |
| | | //alert(spath); |
| | | xaserver::DownLoadFile(GetServerUrl(),spath,"",path+"/"+filename); |
| | | return "file://"+ path+"/"+filename; |
| | | xaserver::DownLoadFile(GetServerUrl(),spath,L"",path+L"/"+filename); |
| | | return (xstring)L"file://"+ path+L"/"+filename; |
| | | } |
| | | |
| | | string DownLoadPaperPic1(string guid) |
| | | xstring DownLoadPaperPic1(xstring guid) |
| | | { |
| | | string path =GetModuleTmpPath(); |
| | | string ext = "jpg"; |
| | | string filename = guid + "." + ext; |
| | | string str = guid.mid(0,2); |
| | | string spath = "/business/products/chanpin/"+str+"/"+guid+".jpg"; |
| | | xaserver::DownLoadFile(GetServerUrl(),spath,"",path+"/"+filename); |
| | | return "file://"+ path+"/"+filename; |
| | | xstring path = xutil::GetModuleTmpPath(); |
| | | xstring ext = L"jpg"; |
| | | xstring filename = guid + L"." + ext; |
| | | xstring str = guid.mid(0,2); |
| | | xstring spath = L"/business/products/chanpin/"+str+L"/"+guid+L".jpg"; |
| | | xaserver::DownLoadFile(GetServerUrl(),spath,L"",path+L"/"+filename); |
| | | return (xstring)L"file://"+ path+L"/"+filename; |
| | | } |
| | | |
| | | string DownLoadUrlPic(string src) |
| | | xstring DownLoadUrlPic(xstring src) |
| | | { |
| | | string guid = publiccode::GetGuid(); |
| | | string path =GetModuleTmpPath(); |
| | | string ext = "jpg"; |
| | | string filename = guid + "." + ext; |
| | | string spath = src; |
| | | xaserver::DownLoadFile(GetServerUrl(),spath,"",path+"/"+filename); |
| | | return "file://"+ path+"/"+filename; |
| | | xstring guid = publiccode::GetGuid(); |
| | | xstring path = xutil::GetModuleTmpPath(); |
| | | xstring ext = L"jpg"; |
| | | xstring filename = guid + L"." + ext; |
| | | xstring spath = src; |
| | | xaserver::DownLoadFile(GetServerUrl(),spath,L"",path+L"/"+filename); |
| | | return (xstring)L"file://"+ path+L"/"+filename; |
| | | } |
| | | |
| | | int OnHtml(xaserverarg arg) |
| | | { |
| | | int hCursor = xutil::SetCursorWait(); |
| | | HCURSOR hCursor = xutil::SetCursorWait(); |
| | | |
| | | string sEntityName = arg.GetArgString("EntityName"); |
| | | string sEntityID = arg.GetArgString("EntityID"); |
| | | string dataUrl = arg.GetArgString("DataUrl"); |
| | | if(dataUrl=="") |
| | | dataUrl = "/sale/data/"+sEntityName+"/print/dataset"; |
| | | else if(dataUrl.left(1)!="/") |
| | | dataUrl = "/sale/data/"+sEntityName+ "/"+ dataUrl; |
| | | xstring sEntityName = arg.GetArgString(L"EntityName"); |
| | | xstring sEntityID = arg.GetArgString(L"EntityID"); |
| | | xstring dataUrl = arg.GetArgString(L"DataUrl"); |
| | | if(dataUrl==L"") |
| | | dataUrl = L"/sale/data/"+sEntityName+L"/print/dataset"; |
| | | else if(dataUrl.left(1)!=L"/") |
| | | dataUrl = L"/sale/data/"+sEntityName+ L"/"+ dataUrl; |
| | | if(!m_dataset) |
| | | { |
| | | xml x0 = new xml; |
| | | x0.setNativePointer(xml::CreateInstance()); |
| | | if (url::get(dataUrl,arg.GetString(),x0) != 1) |
| | | xml x0 ; |
| | | if (xurl::get(dataUrl,arg.GetString(),x0) != 1) |
| | | { |
| | | alert("数据集出错了!"); |
| | | alert(L"数据集出错了!"); |
| | | return 0; |
| | | } |
| | | trace(x0.GetXml()); |
| | | trace(x0.xml()); |
| | | m_dataset = x0; |
| | | } |
| | | |
| | | string sPath; |
| | | xstring sPath; |
| | | sPath = getfilePath(); |
| | | arg.AddArg("sPath",sPath); |
| | | arg.AddArg(L"sPath",sPath); |
| | | m_spath = sPath; |
| | | |
| | | xml xsl = new xml; |
| | | xsl.setNativePointer(xml::CreateInstance()); |
| | | if (url::get("/sale/data/SysPrintTemplate/getxsl",arg.GetString(),xsl) != 1) |
| | | xml xsl; |
| | | if (xurl::get(L"/sale/data/SysPrintTemplate/getxsl", arg.GetString(), xsl) != 1) |
| | | { |
| | | alert("数据模板错误!"); |
| | | alert(L"数据模板错误!"); |
| | | return 0; |
| | | } |
| | | |
| | | string xslStr = xsl.GetXml(); |
| | | xstring xslStr = xsl.xml(); |
| | | |
| | | xslStr = adjustXsl(xslStr,sPath); |
| | | xsl.LoadXml(xslStr); |
| | | xsl.loadXML(xslStr); |
| | | |
| | | //trace(m_dataset.GetXml()); |
| | | trace("\r\n--------\r\n"+xslStr); |
| | | trace(L"\r\n--------\r\n"+xslStr); |
| | | |
| | | m_strHtml = m_dataset.GetXmlDoc().transformNode(xsl.GetXmlDoc()); |
| | | string aspace = m_strHtml.replace("[空]"," ",0); |
| | | aspace = aspace.replace("[line]","<br/>",0); |
| | | string scontent = aspace.replace("<?xml version=\"1.0\"?>","",0); |
| | | m_strHtml = m_dataset.transformNode(xsl); |
| | | xstring aspace = m_strHtml.replace(L"[空]",L" ",0); |
| | | aspace = aspace.replace(L"[line]",L"<br/>",0); |
| | | xstring scontent = aspace.replace(L"<?xml version=\"1.0\"?>",L"",0); |
| | | |
| | | string head =""; |
| | | string tail = scontent; |
| | | xstring head =L""; |
| | | xstring tail = scontent; |
| | | |
| | | int pos = tail.find("src=\"item-picture:"); |
| | | int pos = tail.find(L"src=\"item-picture:"); |
| | | while(pos > 0) |
| | | { |
| | | int spos = pos+"src=\"item-picture:".length(); |
| | | int pos1 = tail.find("\"",spos+1); |
| | | string skuno = tail.mid(spos,pos1 - spos ).trim(); |
| | | string CustomerID=""; |
| | | string CustomerItemNo=""; |
| | | if(skuno.find(",")>0) |
| | | int spos = pos+((xstring)L"src=\"item-picture:").length(); |
| | | int pos1 = tail.find(L"\"",spos+1); |
| | | xstring skuno = tail.mid(spos,pos1 - spos ).trim(); |
| | | xstring CustomerID=L""; |
| | | xstring CustomerItemNo=L""; |
| | | if(skuno.find(L",")>0) |
| | | { |
| | | CustomerID = skuno.left(skuno.find(",")).trim(); |
| | | skuno = skuno.mid(skuno.find(",")+1,256).trim(); |
| | | CustomerID = skuno.left(skuno.find(L",")).trim(); |
| | | skuno = skuno.mid(skuno.find(L",")+1,256).trim(); |
| | | } |
| | | if(skuno.find(",")>0) |
| | | if(skuno.find(L",")>0) |
| | | { |
| | | CustomerItemNo = skuno.left(skuno.find(",")).trim(); |
| | | skuno = skuno.mid(skuno.find(",")+1,256).trim(); |
| | | CustomerItemNo = skuno.left(skuno.find(L",")).trim(); |
| | | skuno = skuno.mid(skuno.find(L",")+1,256).trim(); |
| | | } |
| | | string src = DownLoadSKUNoPic(skuno,CustomerID,CustomerItemNo); |
| | | head += tail.left(pos) + "src=\"" + src; |
| | | xstring src = DownLoadSKUNoPic(skuno,CustomerID,CustomerItemNo); |
| | | head += tail.left(pos) + L"src=\"" + src; |
| | | tail = tail.mid(pos1,999999999); |
| | | pos = tail.find("src=\"item-picture:"); |
| | | pos = tail.find(L"src=\"item-picture:"); |
| | | } |
| | | scontent = head + tail; |
| | | |
| | | head =""; |
| | | head =L""; |
| | | tail = scontent; |
| | | int position = tail.find("src=\"paper-picture:"); |
| | | int position = tail.find(L"src=\"paper-picture:"); |
| | | while(position > 0) |
| | | { |
| | | int sposition = position+"src=\"paper-picture:".length(); |
| | | int position1 = tail.find("\"",sposition+1); |
| | | string guid = tail.mid(sposition,position1 - sposition ).trim(); |
| | | string src2 = DownLoadPaperPic(guid); |
| | | head += tail.left(position) + "src=\"" + src2; |
| | | int sposition = position+ ((xstring)L"src=\"paper-picture:").length(); |
| | | int position1 = tail.find(L"\"",sposition+1); |
| | | xstring guid = tail.mid(sposition,position1 - sposition ).trim(); |
| | | xstring src2 = DownLoadPaperPic(guid); |
| | | head += tail.left(position) + L"src=\"" + src2; |
| | | tail = tail.mid(position1,999999999); |
| | | position = tail.find("src=\"paper-picture:"); |
| | | position = tail.find(L"src=\"paper-picture:"); |
| | | } |
| | | scontent = head + tail; |
| | | |
| | | head =""; |
| | | head =L""; |
| | | tail = scontent; |
| | | position = tail.find("src=\"src-picture:"); |
| | | position = tail.find(L"src=\"src-picture:"); |
| | | while(position > 0) |
| | | { |
| | | sposition = position+"src=\"src-picture:".length(); |
| | | position1 = tail.find("\"",sposition+1); |
| | | guid = tail.mid(sposition,position1 - sposition ).trim(); |
| | | src2 = DownLoadUrlPic(guid); |
| | | head += tail.left(position) + "src=\"" + src2; |
| | | int sposition = position+((xstring)L"src=\"src-picture:").length(); |
| | | int position1 = tail.find(L"\"",sposition+1); |
| | | xstring guid = tail.mid(sposition,position1 - sposition ).trim(); |
| | | xstring src2 = DownLoadUrlPic(guid); |
| | | head += tail.left(position) + L"src=\"" + src2; |
| | | tail = tail.mid(position1,999999999); |
| | | position = tail.find("src=\"src-picture:"); |
| | | position = tail.find(L"src=\"src-picture:"); |
| | | } |
| | | scontent = head + tail; |
| | | |
| | |
| | | htmlStr = scontent; |
| | | ole_print.LoadHtml(scontent); |
| | | |
| | | xml x1 = new xml; |
| | | x1.setNativePointer(xml ::CreateInstance()); |
| | | //string xcontent = m_strHtml.replace(" ","[空]",0); |
| | | string xcontent = m_strHtml.replace("[空]"," ",0); |
| | | int pos0 = xcontent.find("<xml"); |
| | | int pos2 = xcontent.find("</xml>"); |
| | | xml x1; |
| | | //xstring xcontent = m_strHtml.replace(L" ",L"[空]",0); |
| | | xstring xcontent = m_strHtml.replace(L"[空]",L" ",0); |
| | | int pos0 = xcontent.find(L"<xml"); |
| | | int pos2 = xcontent.find(L"</xml>"); |
| | | if(pos0>=0) |
| | | { |
| | | string str = xcontent.left(pos0)+ xcontent.mid(pos2+6,9999999); |
| | | xstring str = xcontent.left(pos0)+ xcontent.mid(pos2+6,9999999); |
| | | xcontent = str; |
| | | } |
| | | x1.LoadXml(xcontent); |
| | | if(x1.GetXmlDoc()) |
| | | x1.loadXML(xcontent); |
| | | if(x1) |
| | | { |
| | | /*if(!showgrid) |
| | | { |
| | | SendCtrlCmd(cell,"xmFormatShowGrid"); |
| | | SendCtrlCmd(cell,L"xmFormatShowGrid"); |
| | | showgrid = true; |
| | | }*/ |
| | | cell.LoadTemplate(x1.GetXmlDoc()); |
| | | cell.LoadTemplate(x1); |
| | | cell.Redraw(); |
| | | } |
| | | |
| | |
| | | |
| | | int updateHtml() |
| | | { |
| | | _mshtml::IHTMLDocument3 doc = ole_print.GetHtmlDocument(); |
| | | _mshtml::IHTMLElementCollection rows = doc.getElementsByTagName("tr"); |
| | | _mshtml::IHTMLElementCollection rows2 = doc.getElementsByTagName("td"); |
| | | int len = rows.length; |
| | | int len2 = rows2.length; |
| | | return 1; |
| | | IHTMLDocument3* doc = (IHTMLDocument3 * )ole_print.GetHtmlDocument(); |
| | | IHTMLElementCollection* rows = NULL; |
| | | IHTMLElementCollection* rows2 = NULL; |
| | | doc->getElementsByTagName((BSTR)L"tr",&rows); |
| | | doc->getElementsByTagName((BSTR)L"td",&rows2); |
| | | long len; |
| | | rows->get_length(&len); |
| | | long len2; |
| | | rows2->get_length(&len2); |
| | | for(int i=0; i < len - 1;i++) |
| | | { |
| | | _mshtml::IHTMLElement e = rows.item(i,i); |
| | | e.style.setAttribute("height",e.offsetHeight,0); |
| | | e.Release(); |
| | | _variant_t var; |
| | | IHTMLElement* e=0; |
| | | IHTMLStyle* pstyle=0; |
| | | long offsetHeight=0; |
| | | rows->item((_variant_t)i, (_variant_t)i,(IDispatch**) & e); |
| | | e->get_style(&pstyle); |
| | | e->get_offsetHeight(&offsetHeight); |
| | | pstyle->setAttribute((BSTR)L"height",(_variant_t)offsetHeight, 0); |
| | | e->Release(); |
| | | pstyle->Release(); |
| | | } |
| | | for( i=0; i < len2 - 1;i++) |
| | | for( int i=0; i < len2 - 1;i++) |
| | | { |
| | | _mshtml::IHTMLElement e2 = rows2.item(i,i); |
| | | e2.style.setAttribute("width",e.offsetWidth,0); |
| | | e2.Release(); |
| | | IHTMLElement* e = 0; |
| | | IHTMLStyle* pstyle = 0; |
| | | long offsetWidth=0; |
| | | rows->item((_variant_t)i, (_variant_t)i, (IDispatch**)&e); |
| | | e->get_style(&pstyle); |
| | | e->get_offsetHeight(&offsetWidth); |
| | | pstyle->setAttribute((BSTR)L"width", (_variant_t)offsetWidth, 0); |
| | | e->Release(); |
| | | pstyle->Release(); |
| | | } |
| | | rows.Release(); |
| | | doc.release(); |
| | | htmlStr = doc.documentElement.outerHtml; |
| | | rows->Release(); |
| | | doc->Release(); |
| | | |
| | | //IHTMLElement* e = 0; |
| | | //doc->get_documentElement(&e); |
| | | //BSTR bstrHtml=0; |
| | | //e->get_outerHTML(&bstrHtml); |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | int OnOpenDocument() |
| | | { |
| | | if(GetParam()) |
| | | if(GetWinParam()) |
| | | { |
| | | xaserverarg arg = new xaserverarg; |
| | | arg.setNativePointer(GetParam()); |
| | | int p = arg.ptr_native_; |
| | | arg.AddArg("action","open"); |
| | | arg.AddArg("DocumentID",""); |
| | | arg.AddArg("ok",""); |
| | | openUrl("/sale/view/view.dlg/xpage/Template/PrintDialog", p); |
| | | string ret = arg.GetArgString("return"); |
| | | string action = arg.GetArgString("action"); |
| | | if (ret =="ok") |
| | | xaserverarg arg=GetArg(); |
| | | arg.AddArg(L"action",L"open"); |
| | | arg.AddArg(L"DocumentID",L""); |
| | | arg.AddArg(L"ok",L""); |
| | | openUrl(L"/sale/view/view.dlg/xpage/Template/PrintDialog", &arg); |
| | | xstring ret = arg.GetArgString(L"return"); |
| | | xstring action = arg.GetArgString(L"action"); |
| | | if (ret ==L"ok") |
| | | { |
| | | if(action =="open") |
| | | if(action ==L"open") |
| | | { |
| | | m_DocumentID = arg.GetArgString("DocumentID"); |
| | | xml x = new xml; |
| | | x.setNativePointer(xml::CreateInstance()); |
| | | string prestr = m_DocumentID.mid(0,2); |
| | | prestr = prestr.upper(); |
| | | xaserver::LoadUrl(GetServerUrl(),"/business/data/bill/"+prestr+"/"+ m_DocumentID+".jpg","",x); |
| | | if(x.GetXml()!="") |
| | | m_DocumentID = arg.GetArgString(L"DocumentID"); |
| | | xml x; |
| | | |
| | | xstring prestr = m_DocumentID.mid(0,2); |
| | | prestr = prestr.toUpper(); |
| | | xaserver::LoadUrl(GetServerUrl(),L"/business/data/bill/"+prestr+L"/"+ m_DocumentID+L".jpg",L"",x); |
| | | if((xstring)x.xml()!=L"") |
| | | { |
| | | if(x.GetXmlDoc()) |
| | | if(x) |
| | | { |
| | | /*if(!showgrid) |
| | | { |
| | | SendCtrlCmd(cell,"xmFormatShowGrid"); |
| | | SendCtrlCmd(cell,L"xmFormatShowGrid"); |
| | | showgrid = true; |
| | | }*/ |
| | | cell.LoadTemplate(x.GetXmlDoc()); |
| | | cell.LoadTemplate(x); |
| | | cell.Redraw(); |
| | | } |
| | | ole_print.LoadHtml(x.GetXml()); |
| | | ole_print.LoadHtml(x.xml()); |
| | | }else |
| | | { |
| | | ole_print.LoadHtml("<html><body>未找到对应的文档</body></html>"); |
| | | //cell.LoadHtml("<html><body>未找到对应的文档</body></html>"); |
| | | ole_print.LoadHtml(L"<html><body>未找到对应的文档</body></html>"); |
| | | //cell.LoadHtml(L"<html><body>未找到对应的文档</body></html>"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | string templateName = arg.GetArgString("template-name"); |
| | | win32::SetWindowText(GetHWND(),templateName); |
| | | xstring templateName = arg.GetArgString(L"template-name"); |
| | | SetWindowText(GetHWND(),templateName); |
| | | billName = templateName; |
| | | billPre = arg.GetArgString("template-pre"); |
| | | billID = arg.GetArgString("template-guid"); |
| | | m_EntityID = arg.GetArgString("EntityID"); |
| | | m_EntityNo = arg.GetArgString("EntityNo"); |
| | | m_EntityName = arg.GetArgString("EntityName"); |
| | | m_DocumentID = ""; |
| | | billPre = arg.GetArgString(L"template-pre"); |
| | | billID = arg.GetArgString(L"template-guid"); |
| | | m_EntityID = arg.GetArgString(L"EntityID"); |
| | | m_EntityNo = arg.GetArgString(L"EntityNo"); |
| | | m_EntityName = arg.GetArgString(L"EntityName"); |
| | | m_SupplierName = arg.GetArgString(L"SupplierName"); |
| | | m_DocumentID = L""; |
| | | |
| | | OnHtml(arg); |
| | | |
| | |
| | | |
| | | int OnPrintDialog() |
| | | { |
| | | if(GetParam()) |
| | | if(GetWinParam()) |
| | | { |
| | | xaserverarg arg = new xaserverarg; |
| | | arg.setNativePointer(GetParam()); |
| | | int p = arg.ptr_native_; |
| | | arg.AddArg("ok",""); |
| | | openUrl("/sale/view/view.dlg/xpage/Template/PrintDialog", p); |
| | | string ret = arg.GetArgString("return"); |
| | | string action = arg.GetArgString("action"); |
| | | if (ret =="ok") |
| | | xaserverarg arg=GetArg(); |
| | | arg.AddArg(L"ok",L""); |
| | | openUrl(L"/sale/view/view.dlg/xpage/Template/PrintDialog", &arg); |
| | | xstring ret = arg.GetArgString(L"return"); |
| | | xstring action = arg.GetArgString(L"action"); |
| | | if (ret ==L"ok") |
| | | { |
| | | updated = false; |
| | | if(action =="open") |
| | | if(action ==L"open") |
| | | { |
| | | m_DocumentID = arg.GetArgString("DocumentID"); |
| | | xml x = new xml; |
| | | x.setNativePointer(xml::CreateInstance()); |
| | | string prestr = m_DocumentID.mid(0,2); |
| | | prestr = prestr.upper(); |
| | | xaserver::LoadUrl(GetServerUrl(),"/business/data/bill/"+prestr+"/"+ m_DocumentID+".jpg","",x); |
| | | if(x.GetXml()!="") |
| | | m_DocumentID = arg.GetArgString(L"DocumentID"); |
| | | xml x; |
| | | |
| | | xstring prestr = m_DocumentID.mid(0,2); |
| | | prestr = prestr.toUpper(); |
| | | xaserver::LoadUrl(GetServerUrl(),L"/business/data/bill/"+prestr+L"/"+ m_DocumentID+L".jpg",L"",x); |
| | | if((xstring)x.xml()!=L"") |
| | | { |
| | | |
| | | string content = ""; |
| | | if(x.GetXmlDoc().documentElement.tagName=="Bill") |
| | | xstring content = L""; |
| | | if((xstring)x.documentElement().tagName() == L"Bill") |
| | | { |
| | | content = x.GetXmlDoc().documentElement.text; |
| | | content = content.replace("[空]"," ",0); |
| | | ole_print.LoadHtml(content); |
| | | content = x.documentElement().text(); |
| | | content = content.replace(L"[空]",L" ",0); |
| | | ole_print.LoadHtml((LPTSTR)content.c_str()); |
| | | }else |
| | | { |
| | | if(x.GetXmlDoc()) |
| | | if(x) |
| | | { |
| | | /*if(!showgrid) |
| | | { |
| | | SendCtrlCmd(cell,"xmFormatShowGrid"); |
| | | SendCtrlCmd(cell,L"xmFormatShowGrid"); |
| | | showgrid = true; |
| | | }*/ |
| | | xml x1 = new xml; |
| | | x1.setNativePointer(xml::CreateInstance()); |
| | | string content1 = x.GetXml(); |
| | | content1 = content1.replace("[空]"," ",0); |
| | | xml x1 ; |
| | | |
| | | xstring content1 = x.xml(); |
| | | content1 = content1.replace(L"[空]",L" ",0); |
| | | //trace(content1); |
| | | x1.LoadXml(content1); |
| | | cell.LoadTemplate(x1.GetXmlDoc()); |
| | | x1.loadXML(content1); |
| | | cell.LoadTemplate(x1); |
| | | cell.Redraw(); |
| | | } |
| | | content = x.GetXml(); |
| | | content = content.replace("[空]"," ",0); |
| | | content = x.xml(); |
| | | content = content.replace(L"[空]",L" ",0); |
| | | ole_print.LoadHtml(content); |
| | | } |
| | | }else |
| | | { |
| | | ole_print.LoadHtml("<html><body>未找到对应的文档</body></html>"); |
| | | //cell.LoadHtml("<html><body>未找到对应的文档</body></html>"); |
| | | ole_print.LoadHtml((LPTSTR)L"<html><body>未找到对应的文档</body></html>"); |
| | | //cell.LoadHtml(L"<html><body>未找到对应的文档</body></html>"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | string templateName = arg.GetArgString("template-name"); |
| | | win32::SetWindowText(GetHWND(),templateName); |
| | | xstring templateName = arg.GetArgString(L"template-name"); |
| | | SetWindowText(GetHWND(),templateName); |
| | | billName = templateName; |
| | | billPre = arg.GetArgString("template-pre"); |
| | | billID = arg.GetArgString("template-guid"); |
| | | m_EntityID = arg.GetArgString("EntityID"); |
| | | m_EntityNo = arg.GetArgString("EntityNo"); |
| | | m_EntityName = arg.GetArgString("EntityName"); |
| | | m_DocumentID = ""; |
| | | billPre = arg.GetArgString(L"template-pre"); |
| | | billID = arg.GetArgString(L"template-guid"); |
| | | m_EntityID = arg.GetArgString(L"EntityID"); |
| | | m_EntityNo = arg.GetArgString(L"EntityNo"); |
| | | m_EntityName = arg.GetArgString(L"EntityName"); |
| | | m_SupplierName = arg.GetArgString(L"SupplierName"); |
| | | m_DocumentID = L""; |
| | | OnHtml(arg); |
| | | } |
| | | } |
| | |
| | | |
| | | int SetAgent() |
| | | { |
| | | string xfNodeAgentArea = "agentarea"; |
| | | xstring xfNodeAgentArea = L"agentarea"; |
| | | xnode anode = GetAgentNode(xfNodeAgentArea); |
| | | msxml::IXMLDOMElement xframeElement = GetElement(); |
| | | msxml::IXMLDOMNode agent = xframeElement.selectSingleNode("agent/"+xfNodeAgentArea+"[1]/*"); |
| | | KXMLDOMElement xframeElement = GetElement(); |
| | | KXMLDOMNode agent = xframeElement.selectSingleNode(L"agent/"+xfNodeAgentArea+L"[1]/*"); |
| | | |
| | | msxml::IXMLDOMNodeList nlist; |
| | | KXMLDOMNodeList nlist; |
| | | int index; |
| | | int nlen; |
| | | msxml::IXMLDOMElement ele; |
| | | string tools="<hbox class=''>"; |
| | | KXMLDOMElement ele; |
| | | xstring tools=L"<hbox class=''>"; |
| | | if(agent) |
| | | { |
| | | nlist = agent.SelectNodes(".//xtoolbutton"); |
| | | nlen = nlist.length; |
| | | nlist = agent.selectNodes(L".//xtoolbutton"); |
| | | nlen = nlist.length(); |
| | | for(index=0;index<nlen;index++) |
| | | { |
| | | ele = nlist.item(index); |
| | | string name = ele.selectSingleNode("@name").text; |
| | | string label = ele.selectSingleNode("@caption").text; |
| | | string image; |
| | | string src = ""; |
| | | if(ele.selectSingleNode("@image")) |
| | | image = ele.selectSingleNode("@image").text; |
| | | xstring name = ele.selectSingleNode(L"@name").text(); |
| | | xstring label = ele.selectSingleNode(L"@caption").text(); |
| | | xstring image; |
| | | xstring src = L""; |
| | | if(ele.selectSingleNode(L"@image")) |
| | | image = ele.selectSingleNode(L"@image").text(); |
| | | else |
| | | image = "0 22"; |
| | | image = L"0 22"; |
| | | |
| | | if(ele.selectSingleNode("@src")) |
| | | src = ele.selectSingleNode("@src").text; |
| | | if(ele.selectSingleNode(L"@src")) |
| | | src = ele.selectSingleNode(L"@src").text(); |
| | | |
| | | int strLen = label.length(); |
| | | int width = 60 + (strLen - 2) * 10; |
| | | string tool; |
| | | if (src != "") |
| | | tool = "<xtoolbutton src='"+src+"' caption='"+label+"' name='"+name+"' height='28' class1='action'/>"; |
| | | xstring tool; |
| | | if (src != L"") |
| | | tool = L"<xtoolbutton src='"+src+L"' caption='"+label+L"' name='"+name+L"' height='28' class1='action'/>"; |
| | | else |
| | | tool = "<xtoolbutton image='"+image+"' caption='"+label+"' name='"+name+"' height='28' class1='action'/>"; |
| | | tool = L"<xtoolbutton image='"+image+L"' caption='"+label+L"' name='"+name+L"' height='28' class1='action'/>"; |
| | | tools += tool; |
| | | } |
| | | } |
| | | tools +="</hbox>"; |
| | | SetAgentNodeContent(anode, tools); |
| | | tools +=L"</hbox>"; |
| | | SetAgentNode(anode, tools); |
| | | return 1; |
| | | } |
| | | |
| | | //焦点激活处理函数 |
| | | int OnSetFocus(ref TNotifyEvent evt,int p) |
| | | int OnSetFocus(TEvent * evt,int p) |
| | | { |
| | | //重置工具条 |
| | | SetAgent(); |
| | |
| | | editing = !editing; |
| | | if(editing) |
| | | { |
| | | SwitchLayer("cellview","viewclient"); |
| | | SwitchLayer(L"cellview",L"viewclient"); |
| | | }else |
| | | { |
| | | htmlStr = cell.GetHtml(); |
| | | //string content = htmlStr; |
| | | htmlStr = htmlStr.replace("[空]"," ",0); |
| | | htmlStr = htmlStr.replace("[line]","<br/>",0); |
| | | //xstring content = htmlStr; |
| | | htmlStr = htmlStr.replace(L"[空]",L" ",0); |
| | | htmlStr = htmlStr.replace(L"[line]",L"<br/>",0); |
| | | ole_print.LoadHtml(htmlStr); |
| | | SwitchLayer("oleview","viewclient"); |
| | | SwitchLayer(L"oleview",L"viewclient"); |
| | | } |
| | | return 1; |
| | | } |
| | |
| | | } |
| | | int PrintPaper() //打印 |
| | | { |
| | | //ole_print.GetHtmlDocument(); |
| | | #ifdef shouldFinish //ole_print.GetHtmlDocument(); |
| | | //return 1; |
| | | _mshtml::IHTMLDocument3 doc = ole_print.GetHtmlDocument(); |
| | | _mshtml::IHTMLElementCollection rows = doc.getElementsByTagName("tr"); |
| | | IHTMLDocument3* doc = (IHTMLDocument3 * )ole_print.GetHtmlDocument(); |
| | | IHTMLElementCollection* rows = doc->getElementsByTagName(L"tr"); |
| | | |
| | | int len = rows.length; |
| | | long len; |
| | | rows->get_length(&len); |
| | | for(int i=0; i < len - 1;i++) |
| | | { |
| | | //oleobject v = rows.item(i,i); |
| | | _mshtml::IHTMLElement e = rows.item(i,i); |
| | | _mshtml::IHTMLElement2 e1 = e; |
| | | //e.setAttribute("height",e1.clientHeight,0); |
| | | e.setAttribute("height",300,0); |
| | | IHTMLElement* e = rows->item(i,i); |
| | | IHTMLElement2* e1 = e; |
| | | //e.setAttribute(L"height",e1.clientHeight,0); |
| | | e.setAttribute(L"height",300,0); |
| | | e.Release(); |
| | | e1.Release(); |
| | | } |
| | | rows.Release(); |
| | | doc.Release(); |
| | | #endif |
| | | /* |
| | | if(PaperPrint == false) |
| | | { |
| | | ole_print.GetHtmlDocument().body.style.visibility="hidden"; |
| | | ole_print.GetHtmlDocument().body.style.visibility=L"hidden"; |
| | | PaperPrint = true; |
| | | } |
| | | else |
| | | { |
| | | ole_print.GetHtmlDocument().body.style.visibility="visible"; |
| | | ole_print.GetHtmlDocument().body.style.visibility=L"visible"; |
| | | PaperPrint = false; |
| | | } |
| | | */ |
| | |
| | | } |
| | | int OnPortrait() //纵向 |
| | | { |
| | | alert("Portrait"); |
| | | alert(L"Portrait"); |
| | | return 1; |
| | | } |
| | | int OnLandscape() //横向 |
| | |
| | | |
| | | int OnAddToDocument() |
| | | { |
| | | string content = htmlStr; |
| | | xstring content = htmlStr; |
| | | if(editing)content = cell.GetHtml(); |
| | | string guid = publiccode::GetGuid(); |
| | | xstring guid = publiccode::GetGuid(); |
| | | |
| | | string prestr = guid.mid(0,2); |
| | | prestr = prestr.upper(); |
| | | xstring prestr = guid.mid(0,2); |
| | | prestr = prestr.toUpper(); |
| | | |
| | | |
| | | content = content.replace("gb2312","utf-16",0); |
| | | content = content.replace(" ","[空]",0); |
| | | content = content.replace("&","",0); |
| | | content = content.replace(L"gb2312",L"utf-16",0); |
| | | content = content.replace(L" ",L"[空]",0); |
| | | content = content.replace(L"&",L"",0); |
| | | |
| | | xml x0 = new xml; |
| | | x0.setNativePointer(xml::CreateInstance()); |
| | | x0.LoadXml("<Bill/>"); |
| | | x0.GetXmlDoc().documentElement.text = content; |
| | | content = x0.GetXml(); |
| | | xml x0 ; |
| | | x0.loadXML(L"<Bill/>"); |
| | | x0.documentElement().settext(content); |
| | | content = x0.xml(); |
| | | |
| | | int ret= xaserver::UploadData("bill"+prestr, guid+".jpg", content); |
| | | if(ret < 0) trace("error upload"); |
| | | int ret= xaserver::UploadData(L"bill"+prestr, guid+L".jpg", content); |
| | | if(ret < 0) trace(L"error upload"); |
| | | |
| | | string ls_xml ="<DocumentList guid='"+guid+"' update.modify='1' update.new='1'>"; |
| | | ls_xml += "<EntityName>"+ m_EntityName + "</EntityName>"; |
| | | ls_xml += "<EntityID>"+ m_EntityID + "</EntityID>"; |
| | | ls_xml += "<EntityNo>"+ m_EntityNo + "</EntityNo>"; |
| | | ls_xml += "<BillID>"+ billID + "</BillID>"; |
| | | ls_xml += "<BillName>"+ billName + "</BillName>"; |
| | | ls_xml += "</DocumentList>"; |
| | | xstring ls_xml =L"<DocumentList guid='"+guid+L"' update.modify='1' update.new='1'>"; |
| | | ls_xml += L"<EntityName>"+ m_EntityName + L"</EntityName>"; |
| | | ls_xml += L"<EntityID>"+ m_EntityID + L"</EntityID>"; |
| | | ls_xml += L"<EntityNo>"+ m_EntityNo + L"</EntityNo>"; |
| | | ls_xml += L"<BillID>"+ billID + L"</BillID>"; |
| | | ls_xml += L"<BillName>"+ billName + L"</BillName>"; |
| | | ls_xml += L"</DocumentList>"; |
| | | |
| | | xml x = new xml; |
| | | x.setNativePointer(xml::CreateInstance()); |
| | | x.LoadXml(ls_xml); |
| | | xaserverarg arg = new xaserverarg; |
| | | arg.setNativePointer(xaserverarg::CreateInstance()); |
| | | arg.AddArg("content",x.GetXml()); |
| | | xml x; |
| | | |
| | | if(url::get("/sale/data/DocumentList3/bill/update", arg.GetString(),x)!=1) |
| | | x.loadXML(ls_xml); |
| | | xaserverarg arg; |
| | | |
| | | arg.AddArg(L"content", x.xml()); |
| | | |
| | | if(xurl::get(L"/sale/data/DocumentList3/bill/update", arg.GetString(),x)!=1) |
| | | { |
| | | string error = x.GetXmlDoc().text; |
| | | alert("err:"+error); |
| | | xstring error = x.text(); |
| | | alert(L"err:"+error); |
| | | return 1; |
| | | } |
| | | string str = x.GetXmlDoc().documentElement.getAttribute("text"); |
| | | if(str == "true") |
| | | xstring str = x.documentElement().getAttribute(L"text"); |
| | | if(str == L"true") |
| | | { |
| | | alert("保存成功!"); |
| | | alert(L"保存成功!"); |
| | | updated = false; |
| | | }else |
| | | { |
| | | alert("保存失败!"); |
| | | alert(L"保存失败!"); |
| | | } |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | int SendCtrlCmd(xcontrol xc, string cmd) |
| | | int SendCtrlCmd(xcontrol xc, xstring cmd) |
| | | { |
| | | win32::SendMessage(xc.GetId(),0x401,cmd,0); |
| | | SendMessage(xc.GetHWND(), 0x401, (WPARAM)cmd.c_str(), 0); |
| | | return 1; |
| | | } |
| | | |
| | | int OnRefreshData() |
| | | { |
| | | xaserverarg arg = new xaserverarg; |
| | | arg.setNativePointer(GetParam()); |
| | | string templateName = arg.GetArgString("template-name"); |
| | | win32::SetWindowText(GetHWND(),templateName); |
| | | xaserverarg arg; |
| | | xstring templateName = arg.GetArgString(L"template-name"); |
| | | SetWindowText(GetHWND(),templateName); |
| | | OnHtml(arg); |
| | | billName = templateName; |
| | | billPre = arg.GetArgString("template-pre"); |
| | | billID = arg.GetArgString("template-guid"); |
| | | m_EntityID = arg.GetArgString("EntityID"); |
| | | m_EntityNo = arg.GetArgString("EntityNo"); |
| | | m_EntityName = arg.GetArgString("EntityName"); |
| | | m_DocumentID = ""; |
| | | billPre = arg.GetArgString(L"template-pre"); |
| | | billID = arg.GetArgString(L"template-guid"); |
| | | m_EntityID = arg.GetArgString(L"EntityID"); |
| | | m_EntityNo = arg.GetArgString(L"EntityNo"); |
| | | m_EntityName = arg.GetArgString(L"EntityName"); |
| | | m_SupplierName = arg.GetArgString(L"SupplierName"); |
| | | m_DocumentID = L""; |
| | | return 1; |
| | | } |
| | | |
| | | int OnCmdDispatch(string comdid) |
| | | int OnCmdDispatch(xstring comdid) |
| | | { |
| | | if(comdid=="xmSort") |
| | | if(comdid==L"xmSort") |
| | | { |
| | | OpenWindow("dev:xpage[DataSort.dialog.vx]",cast(m_dataset as int)); |
| | | //OpenWindow(L"dev:xpage[DataSort.dialog.vx]",cast(m_dataset as int)); |
| | | return 1; |
| | | } |
| | | if(comdid=="print:PrintImmediate") |
| | | if(comdid==L"print:PrintImmediate") |
| | | { |
| | | updated = true; |
| | | return OnPrint(); |
| | | } |
| | | if(comdid=="print:PrintPaper") { |
| | | if(comdid==L"print:PrintPaper") { |
| | | updated = true; |
| | | return PrintPaper(); |
| | | } |
| | | if(comdid=="print:PrintPreview") { |
| | | if(comdid==L"print:PrintPreview") { |
| | | updated = true; |
| | | return OnPrintPreview(); |
| | | } |
| | | if(comdid=="print:Portrait") { |
| | | if(comdid==L"print:Portrait") { |
| | | updated = true; |
| | | return OnPortrait(); |
| | | } |
| | | if(comdid=="print:Landscape") { |
| | | if(comdid==L"print:Landscape") { |
| | | updated = true; |
| | | return OnLandscape(); |
| | | } |
| | | if(comdid=="print:PageSetup") { |
| | | if(comdid==L"print:PageSetup") { |
| | | updated = true; |
| | | return OnPageSetup(); |
| | | } |
| | | if(comdid=="print:Custom") { |
| | | if(comdid==L"print:Custom") { |
| | | updated = true; |
| | | return OnCustom(); |
| | | } |
| | | if(comdid=="print:PrintDialog") |
| | | if(comdid==L"print:PrintDialog") |
| | | { |
| | | if(updated) |
| | | { |
| | | int res = win32::MessageBox(this.GetHWND(), "单据已制作,是否保存?","提示",4); |
| | | if(res == 6)OnCmdDispatch("print:AddToDocumentList"); |
| | | int res = MessageBox(GetHWND(), L"单据已制作,是否保存?",L"提示",4); |
| | | if(res == 6)OnCmdDispatch(L"print:AddToDocumentList"); |
| | | } |
| | | if(GetParam()) |
| | | if(GetWinParam()) |
| | | { |
| | | xaserverarg arg1 = new xaserverarg; |
| | | arg1.setNativePointer(GetParam()); |
| | | arg1.AddArg("action","new"); |
| | | xaserverarg arg1 = GetArg(); |
| | | arg1.AddArg(L"action",L"new"); |
| | | OnPrintDialog(); |
| | | arg1.AddArg("action",""); |
| | | arg1.AddArg(L"action",L""); |
| | | } |
| | | return 1; |
| | | } |
| | | if(comdid.find("print:toExcel",0)>=0) { |
| | | if(comdid.find(L"print:toExcel",0)>=0) { |
| | | updated = true; |
| | | return OntoExcel(); |
| | | } |
| | | if(comdid.find("print:Export",0)>=0) { |
| | | if(comdid.find(L"print:Export",0)>=0) { |
| | | updated = true; |
| | | return OnExport(); |
| | | } |
| | | if(comdid.find("print:SaveAs",0)>=0) return OnSaveAs(); |
| | | if(comdid.find("print:Edit",0)>=0) { |
| | | if(comdid.find(L"print:SaveAs",0)>=0) return OnSaveAs(); |
| | | if(comdid.find(L"print:Edit",0)>=0) { |
| | | updated = true; |
| | | return OnEdit(); |
| | | } |
| | | if(comdid.find("action:Close",0)>=0) return CloseWindow(); |
| | | if(comdid=="print:OpenDocument") return OnOpenDocument(); |
| | | if(comdid=="print:AddToDocumentList") return OnAddToDocument(); |
| | | if(comdid.find("action:",0)>=0) return ProcessFlowAction(comdid, 1); |
| | | if(comdid.find(L"action:Close",0)>=0) return CloseWindow(); |
| | | if(comdid==L"print:OpenDocument") return OnOpenDocument(); |
| | | if(comdid==L"print:AddToDocumentList") return OnAddToDocument(); |
| | | if(comdid.find(L"action:",0)>=0) return ProcessFlowAction(comdid, 1); |
| | | |
| | | if(comdid.left(3) == "xmSort") |
| | | if(comdid.left(3) == L"xmSort") |
| | | { |
| | | //string str = |
| | | //xstring str = |
| | | return 1; |
| | | } |
| | | |
| | | if(comdid.left(3) == "IK_") |
| | | if(comdid.left(3) == L"IK_") |
| | | { |
| | | string cmd = comdid.mid(3, comdid.length()); |
| | | xstring cmd = comdid.mid(3, comdid.length()); |
| | | SendCtrlCmd(cell,cmd); |
| | | return 1; |
| | | } |
| | | if(comdid=="print:MaintTemplate") |
| | | if(comdid==L"print:MaintTemplate") |
| | | { |
| | | OpenWindow("dev:xpage[Maint.Template.Print.vx]"); |
| | | OpenWindow(L"dev:xpage[Maint.Template.Print.vx]"); |
| | | return 1; |
| | | } |
| | | if(comdid == "print:RefreshData"){ |
| | | if(comdid == L"print:RefreshData"){ |
| | | return OnRefreshData(); |
| | | } |
| | | |
| | | if(comdid == "xxx") |
| | | if(comdid == L"xxx") |
| | | { |
| | | ole_print.ExecWB(27,0); |
| | | return 1; |
| | | alert("xxx"); |
| | | xml x1 = new xml; |
| | | x1.setNativePointer(xml::CreateInstance()); |
| | | xaserver::ExecXQuery(GetServerUrl(), "[xsl.getdevobj.xq]","<args/>",x1); |
| | | alert(L"xxx"); |
| | | xml x1 ; |
| | | |
| | | xaserver::ExecXQuery(GetServerUrl(), L"[xsl.getdevobj.xq]",L"<args/>",x1); |
| | | } |
| | | |
| | | if(comdid == "xxx") |
| | | if(comdid == L"xxx") |
| | | { |
| | | xml x = new xml; |
| | | x.setNativePointer(xml::CreateInstance()); |
| | | xaserverarg arg = new xaserverarg; |
| | | arg.setNativePointer(arg.CreateInstance()); |
| | | arg.AddArg("strHtml",m_strHtml); |
| | | if (url::get("/sale/data/SysPrintTemplate/WebBrowser",arg.GetString(),x) != 1) |
| | | xml x; |
| | | |
| | | xaserverarg arg; |
| | | |
| | | arg.AddArg(L"strHtml",m_strHtml); |
| | | if (xurl::get(L"/sale/data/SysPrintTemplate/WebBrowser",arg.GetString(),x) != 1) |
| | | { |
| | | alert("数据集出错了!"); |
| | | alert(L"数据集出错了!"); |
| | | return 0; |
| | | } |
| | | string strHtml = x.GetXml(); |
| | | xstring strHtml = x.xml(); |
| | | ole_print.LoadHtml(strHtml); |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | int OnXCommand(ref TXCommandEvent evt,int p) |
| | | int OnXCommand(TEvent* evt,int p) |
| | | { |
| | | return OnCmdDispatch(evt.pStrID); |
| | | return OnCmdDispatch(evt->xcommand.pStrID); |
| | | } |
| | | |
| | | int OnAttachEvent() |
| | | { |
| | | AttachEvent("WM_XCOMMAND",OnXCommand); |
| | | AttachEvent("WM_SETFOCUS",OnSetFocus); |
| | | //AttachEvent("WM_CLOSE",OnCloseOwnerWindow); |
| | | AttachEvent(L"WM_XCOMMAND",(FEvent)& TemplatePrintViewEx::OnXCommand); |
| | | AttachEvent(L"WM_SETFOCUS", (FEvent)&TemplatePrintViewEx::OnSetFocus); |
| | | //AttachEvent(L"WM_CLOSE",OnCloseOwnerWindow); |
| | | |
| | | return 0; |
| | | } |
| | |
| | | { |
| | | if(!updated) return 1; |
| | | |
| | | int MB_YESNOCANCEL = 3; |
| | | int IDYES = 6; |
| | | int IDNO = 7; |
| | | int IDCANCEL = 2; |
| | | int re = win32::MessageBox(this.GetHWND(), "单据已制作,是否保存?","提示:",MB_YESNOCANCEL); |
| | | //int MB_YESNOCANCEL = 3; |
| | | //int IDYES = 6; |
| | | //int IDNO = 7; |
| | | //int IDCANCEL = 2; |
| | | int re = MessageBox(GetHWND(), L"单据已制作,是否保存?",L"提示:",MB_YESNOCANCEL); |
| | | if(re==IDCANCEL) return -1; |
| | | if(re==IDNO) return 1; |
| | | OnCmdDispatch("print:AddToDocumentList"); |
| | | OnCmdDispatch(L"print:AddToDocumentList"); |
| | | return -1; |
| | | } |
| | | |
| | |
| | | { |
| | | OnAttachEvent(); |
| | | AttachCloseWindow(); |
| | | ole_print = GetControl("ole_print"); |
| | | cell = GetControl("xcell"); |
| | | ole_print = GetControl(L"ole_print"); |
| | | cell = GetControl(L"xcell"); |
| | | |
| | | //showgrid = false; |
| | | editing = false; |
| | | SetAgent(); |
| | | |
| | | m_dataset = 0; |
| | | billName = ""; |
| | | billID = ""; |
| | | billPre = ""; |
| | | m_DocumentID = ""; |
| | | billName = L""; |
| | | billID = L""; |
| | | billPre = L""; |
| | | m_DocumentID = L""; |
| | | PaperPrint = false; |
| | | |
| | | return 1; |
| | |
| | | int onloaded() |
| | | { |
| | | updated = false; |
| | | if(GetParam()) |
| | | SetArg(); |
| | | if(GetWinParam()) |
| | | { |
| | | xaserverarg arg = new xaserverarg; |
| | | arg.setNativePointer(GetParam()); |
| | | string templateName = arg.GetArgString("template-name"); |
| | | if(templateName =="") |
| | | xaserverarg arg= GetArg(); |
| | | xstring templateName = arg.GetArgString(L"template-name"); |
| | | if(templateName ==L"") |
| | | { |
| | | OnPrintDialog(); |
| | | } |
| | | |
| | | else |
| | | { |
| | | win32::SetWindowText(GetHWND(),templateName); |
| | | SetWindowText(GetHWND(),templateName); |
| | | OnHtml(arg); |
| | | billName = templateName; |
| | | billPre = arg.GetArgString("template-pre"); |
| | | billID = arg.GetArgString("template-guid"); |
| | | m_EntityID = arg.GetArgString("EntityID"); |
| | | m_EntityNo = arg.GetArgString("EntityNo"); |
| | | m_EntityName = arg.GetArgString("EntityName"); |
| | | m_DocumentID = ""; |
| | | billPre = arg.GetArgString(L"template-pre"); |
| | | billID = arg.GetArgString(L"template-guid"); |
| | | m_EntityID = arg.GetArgString(L"EntityID"); |
| | | m_EntityNo = arg.GetArgString(L"EntityNo"); |
| | | m_EntityName = arg.GetArgString(L"EntityName"); |
| | | m_SupplierName = arg.GetArgString(L"SupplierName"); |
| | | m_DocumentID = L""; |
| | | } |
| | | }else |
| | | OnPrintDialog(); |
| | | return 1; |
| | | } |
| | | }; |
| | | |
| | | }; |
| | | #define _XWIN |