4 Star 0 Fork 2

leegoobin/AutoPHS

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
MainFrm.cpp 92.80 KB
一键复制 编辑 原始数据 按行查看 历史
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236
// MainFrm.cpp : implementation of the CMainFrame class
//
#include "stdafx.h"
#include "AutoPHS.h"
#include "DlgDBOper.h" //LFX 2005.2.26加
#include "MainFrm.h"
#include <math.h>
#include "PhsData.h"
#include "FrmStatus.h"
#include "PhsStart.h"
#include "modPHScal.h"
#include "EDIBgbl.h"
#include "EDIBAcad.h"
#include "ModEncrypt.h"
#include "basDirectory.h"
#include "FrmTxsr.h"
#include "Cphs.h"
#include "PSDstart.h"
#include "FrmSelSpecification.h"
#include "FrmSelPDSV.h"
#include "userphs.h"
#include "FrmAddSArecord.h"
#include "FrmPreferences.h"
#include "FrmDatabaseIn.h"
//#include "FrmDataFormat.h"
#include "EDIBDB.h"
#include "READPSARESULT.h"
#include "FrmTK.h"
#include "FrmFolderLocation.h"
#include "InputBox.h"
#include "StatusBarThread.h"
#include "FrmDataEDIT.h"
#include "DlgAddMaterial.h"
#include "DlgSpan.h"
#include "DlgEditDB.h"
#include "PDMSCore.h"
#include "CalStructDlg.h"
#include "SelTemplate.h"
#include "DlgModifyZdjh.h"
#include <AFXCONV.h>
#include "FileDialogEx.h"
#include "DlgExportVolume.h"
#include "DlgBackupUndo.h"
#include "userphs.h"
#include "modregistry.h"
#include "TBFormatDlg.h"
#include "SelEngVolDll.h"
#include "modSelPdSV.h"
#include "DlgDataFormatDll.h"
#include "ChangMaterilName.h"
#include "ExportPaint.h"
#include "ImportPlantVision.h"
#include "SelectXYZdlg.h";
#include "Guide.h"
#define REG_CALL(CALL,MSG) \
if(ERROR_SUCCESS != CALL) \
{\
AfxMessageBox(MSG);\
}
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define ID_TIME1 100
BOOL gStartAcad();
bool bIsCom = false;//用COM画为true; arx画为false; 1/12
//_declspec(dllexport) extern CDlgDBOper dlgDBOper;
/////////////////////////////////////////////////////////////////////////////
// CMainFrame
IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
//{{AFX_MSG_MAP(CMainFrame)
ON_WM_SETFOCUS()
ON_WM_SIZE()
ON_WM_CREATE()
ON_COMMAND(ID_INT_TABINT, OnIntTabint)
ON_WM_DESTROY()
ON_WM_TIMER()
ON_COMMAND(ID_FILE_NEWDWG, OnFileNewDwg)
ON_WM_SIZING()
ON_COMMAND(ID_INT_IMGINT, OnIntImgint)
ON_WM_SHOWWINDOW()
ON_WM_ACTIVATE()
ON_COMMAND(ID_INT_SELPRO, OnSelPDSV)
ON_COMMAND(ID_INT_TEM, OnSampleManage)
ON_COMMAND(ID_INT_ADDDATA, OnInputSArec)
ON_COMMAND(ID_COU_ONEZDJ, OnCalcZdjh)
ON_COMMAND(ID_DRAW_ZDJ, OnDrawZdj)
ON_COMMAND(ID_FILE_STARTACAD, OnStartacad)
ON_COMMAND(ID_FILE_SELCRI, OnSelPreferences)
ON_COMMAND(ID_FILE_OPT, OnFileOpt)
ON_COMMAND(ID_INT_IMPDATA, OnIntImpdata)
ON_COMMAND(ID_FOR_SEL, OnSetTableFormat)
ON_COMMAND(ID_SUM_ACAD, OnSumAcad)
ON_COMMAND(ID_SUM_EXC, OnSumExc)
ON_COMMAND(ID_SUM_TXT, OnSumTxt)
ON_COMMAND(ID_SUM_ACAD2, OnSumAcad2)
ON_COMMAND(ID_INT_NUM, OnIntPipeana)
ON_COMMAND(ID_FILE_SELDIR, OnFileSelDir)
ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
ON_COMMAND(ID_FILE_SAVE, OnFileSave)
ON_COMMAND(ID_FILE_SAVEAS, OnFileSaveAs)
ON_COMMAND(ID_FILE_CLOSEACAD, OnFileCloseAcad)
ON_UPDATE_COMMAND_UI(ID_FILE_SAVE, OnUpdateFileSave)
ON_UPDATE_COMMAND_UI(ID_FILE_NEWDWG, OnUpdateFileNewOpen)
ON_COMMAND(ID_COU_ALLZDJ, OnCalAllzdj)
ON_COMMAND(ID_FILE_CLOEXC, OnFileCloseExcel)
ON_COMMAND(ID_DRAW_ZDJTAB18, OnDrawZdjTab180)
ON_COMMAND(ID_DRAW_ZDJTAB27, OnDrawZdjTab270)
ON_COMMAND(ID_ZDJ_DRAWEP, OnZdjDrawEP)
ON_COMMAND(ID_ZDJ_DRAWPC, OnZdjDrawPC)
ON_COMMAND(ID_DRAW_ZDJDIR, OnDrawZdjTML)
ON_COMMAND(ID_ERASE_ALL, OnEraseAll)
ON_COMMAND(ID_ERASE_LAYER, OnEraseLayer)
ON_COMMAND(ID_CAD_CEL, OnCadCel)
ON_COMMAND(ID_CAD_MENU, OnCadMenu)
ON_COMMAND(ID_DELETE_LAYER_TAG, OnDeleteLayerTag)
ON_COMMAND(ID_COU_SHOWTAB, OnCouShowtab)
ON_COMMAND(ID_DRAW_CHANGEDIM, OnDrawChangeDim)
ON_COMMAND(ID_REC_FILE1, OnRecFile1)
ON_COMMAND(ID_REC_FILE2, OnRecFile2)
ON_COMMAND(ID_REC_FILE3, OnRecFile3)
ON_COMMAND(ID_REC_FILE4, OnRecFile4)
ON_COMMAND(ID_REC_FILE5, OnRecFile5)
ON_COMMAND(ID_REC_FILE6, OnRecFile6)
ON_COMMAND(ID_REC_FILE7, OnRecFile7)
ON_COMMAND(ID_REC_FILE8, OnRecFile8)
ON_UPDATE_COMMAND_UI(ID_SPEC_PA, OnUpdateSpecPa)
ON_UPDATE_COMMAND_UI(ID_SPEC_CSPR, OnUpdateSpecCspr)
ON_UPDATE_COMMAND_UI(ID_SPEC_BOLTS, OnUpdateSpecBolts)
ON_UPDATE_COMMAND_UI(ID_SPEC_PART, OnUpdateSpecPart)
ON_UPDATE_COMMAND_UI(ID_SPEC_SA, OnUpdateSpecSa)
ON_UPDATE_COMMAND_UI(ID_SPEC_SPR, OnUpdateSpecSpr)
ON_COMMAND(ID_CAL_ADDMATERIAL, OnCalAddmaterial)
ON_COMMAND(ID_CAL_ALLOWMAXSPAN, OnCalAllowMaxSpan)
ON_COMMAND(ID_DRAW_ZDJTABL, OnDrawZdjtabl)
ON_COMMAND(ID_DRAW_ZDJTABL_EXCE, OnDrawZdjtablExce)
ON_COMMAND(ID_SUM_EXCEL, OnSumExcel)
ON_COMMAND(ID_DRAW_ZDJDIR_EXECL, OnDrawZdjdirExecl)
ON_COMMAND(ID_FILE_OPEN_DB, OnFileOpenDb)
ON_COMMAND(ID_TOOL_WBLOCK, OnToolWblock)
ON_COMMAND(ID_TOOL_INSERTUSERBLOCK, OnToolInsertUserBlock)
ON_UPDATE_COMMAND_UI(ID_TOOL_WBLOCK, OnUpdateToolWblock)
ON_UPDATE_COMMAND_UI(ID_TOOL_INSERTUSERBLOCK, OnUpdateToolInsertuserblock)
ON_COMMAND(ID_PDMSTOPHS, OnPdmstophs)
ON_WM_GETMINMAXINFO()
ON_WM_MOVING()
ON_COMMAND(ID_PHSTOPDMS, OnPhstToPdms)
ON_UPDATE_COMMAND_UI(ID_PDMSTOPHS, OnUpdatePdmsToPhs)
ON_UPDATE_COMMAND_UI(ID_PHSTOPDMS, OnUpdatePhsToPdms)
ON_COMMAND(ID_CAL_STRUCT, OnCalStruct)
ON_WM_CLOSE()
ON_UPDATE_COMMAND_UI(ID_INT_IMPDATA, OnUpdateIntImpdata)
ON_COMMAND(ID_MODIFY_ZDJH, OnModifyZdjh)
ON_COMMAND(ID_GUIDE_ENTER,OnGuideEnter)
ON_COMMAND(ID_ZDJ_XN, OnZdjXn)
ON_COMMAND(ID_FILE_BACKUP_DB, OnFileBackupDB)
ON_COMMAND(ID_FILE_RESTORE_DB, OnFileRestoreDB)
ON_COMMAND(ID_AUTO_UPDATE, OnAutoUpdate)
ON_MESSAGE(WM_QUIT_CUS,OnQuitCus)
ON_COMMAND(ID_DRAW_ZDJ_ARX, OnDrawZdjArx)
ON_UPDATE_COMMAND_UI(ID_DRAW_ZDJ, OnUpdateDrawZdj)
ON_COMMAND(ID_ZDJ_DRAWEP_HSY, OnZdjDrawepHsy)
ON_COMMAND(ID_MENUITEM_CHANGMATERIAL, OnMenuitemChangmaterial)
ON_COMMAND(ID_ZDJ_DRAWEP_QGY, OnZdjDrawepQgy)
ON_COMMAND(ID_ZDJ_HBYJ, OnZdjHbyj)
ON_COMMAND(ID_PHS_TO_AUTOIPED, OnPhsToAutoiped)
ON_COMMAND(ID_COMMDBOPER, OnCommdboper)
ON_COMMAND(IDC_ZDJ_ADRAWBJHY, OnZdjAdrawbjhy)
ON_COMMAND(IDC_ZDJ_BDRAWBJHY, OnZdjBdrawbjhy)
ON_COMMAND(IDC_MENU_ImportAutoPHS, OnMENUImportAutoPHS)
ON_UPDATE_COMMAND_UI(ID_FILE_SAVEAS, OnUpdateFileSave)
ON_UPDATE_COMMAND_UI(ID_FILE_OPEN, OnUpdateFileNewOpen)
ON_UPDATE_COMMAND_UI(ID_FILE_STARTACAD, OnUpdateFileNewOpen)
ON_COMMAND(IDM_PLANTVISION_TO_PHS, OnPlantvisionToPhs)
//}}AFX_MSG_MAP
ON_MESSAGE(WM_UPD_OPTION , OnUpdOption)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction
CMainFrame::CMainFrame()
{
// TODO: add member initialization code here
m_nRecFileNum=0;
m_bIsExitMsg=true;
}
//CMainFrame::~CMainFrame()
//{
//}
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CFrameWnd::PreCreateWindow(cs) )
return FALSE;
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
cs.dwExStyle &= ~WS_EX_CLIENTEDGE;
cs.lpszClass = AfxRegisterWndClass( 0,::LoadCursor(::AfxGetInstanceHandle(),IDC_ARROW),
(HBRUSH)COLOR_WINDOW,::LoadIcon(::AfxGetInstanceHandle(),MAKEINTRESOURCE(IDR_MAINFRAME)));
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CMainFrame diagnostics
#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
CFrameWnd::AssertValid();
}
void CMainFrame::Dump(CDumpContext& dc) const
{
CFrameWnd::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers
BOOL CMainFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
{
// TODO: Add your specialized code here and/or call the base class
return CFrameWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
}
void CMainFrame::OnSetFocus(CWnd* pOldWnd)
{
CFrameWnd::OnSetFocus(pOldWnd);
// TODO: Add your message handler code here
}
void CMainFrame::OnSize(UINT nType, int cx, int cy)
{
CFrameWnd::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
//CRect rc1;
//::SystemParametersInfo(SPI_GETWORKAREA,0,(LPVOID)&rc1,0);
//this->SetWindowPos(NULL,0,0,rc1.Width(),GetMenuHeight(),SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE);
}
LRESULT CMainFrame::OnQuitCus(WPARAM wParam,LPARAM lParam)
{
exit(1);
}
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
return 0;
}
void CMainFrame::OnIntTabint()
{
// TODO: Add your command handler code here
if(FrmPhsData.m_hWnd==NULL)
{
FrmPhsData.Create(IDD_PHSDATA,NULL);
}
FrmPhsData.ShowWindow(SW_SHOWNORMAL );
FrmPhsData.SetWindowPos(&wndTop,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
}
void CMainFrame::OnDestroy()
{
SetRegValue(_T("Settings"),_T("MainWndHandle"),CString());
ModEncrypt::EncryptLogout();
if(IsWindow(FrmPhsData.m_hWnd))
FrmPhsData.DestroyWindow();
if(IsWindow(frmStatus.m_hWnd))
frmStatus.DestroyWindow();
if(IsWindow(FrmDataEDIT.m_hWnd))
FrmDataEDIT.DestroyWindow();
if(IsWindow(frmSelPDSV.m_hWnd))
frmSelPDSV.DestroyWindow();
// TODO: Add your message handler code here
if(Cavphs != NULL)
{
delete Cavphs;
Cavphs = NULL;
}
// delete Cavphs;
if(IsWindow(FrmTxsr.m_hWnd))
FrmTxsr.DestroyWindow();
EDIBgbl::CloseAll_ConnectionPtr();
/*try{
if(modPHScal::dbZDJcrude.IsOpen())
{
modPHScal::dbZDJcrude.Close();
}
}
catch(_com_error& e)
{
ShowMessage((char*)e.Description());
}*/
CFrameWnd::OnDestroy();
}
void CMainFrame::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
CFrameWnd::OnTimer(nIDEvent);
}
void CMainFrame::SetMenuEnabled()
{
}
void CMainFrame::OnFileNewDwg()
{
// TODO: Add your command handler code here
this->DDEFileCmd(0);
}
void CMainFrame::OnSizing(UINT fwSide, LPRECT pRect)
{
CFrameWnd::OnSizing(fwSide, pRect);
// TODO: Add your message handler code here
CRect rc;
GetWindowRect(&rc);
pRect->left=rc.left;
pRect->top=rc.top;
pRect->bottom=rc.bottom;
pRect->right=rc.right;
}
void CMainFrame::OnIntImgint()
{
// TODO: Add your command handler code here
FrmTxsr.m_IsFirst=false;//pfg20050216
if(!IsWindow(FrmTxsr.m_hWnd))
{
FrmTxsr.Create(this);
}
if(IsWindow(FrmTxsr.m_hWnd))
{
FrmTxsr.ShowWindow(SW_SHOWNORMAL);
FrmTxsr.SetWindowPos(&wndTop,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
}
}
void CMainFrame::OnShowWindow(BOOL bShow, UINT nStatus)
{
CFrameWnd::OnShowWindow(bShow, nStatus);
// TODO: Add your message handler code here
CRect rc1;
::SystemParametersInfo(SPI_GETWORKAREA,0,(LPVOID)&rc1,0);
this->SetWindowPos(NULL,0,0,rc1.Width(),GetMenuHeight(),SWP_NOZORDER|SWP_NOACTIVATE);
}
void CMainFrame::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized)
{
CFrameWnd::OnActivate(nState, pWndOther, bMinimized);
}
void CMainFrame::OnSelPDSV()
{
// TODO: Add your command handler code here
modPHScal::SelInputMethod = 2;
CSelEngVolDll dlg;
LPTSTR lpstrAllPrjDBPathName;
LPTSTR lpstrsortPathName;
LPTSTR lpstrworkprjPathName;
//20071105 " basDirectory::DBShareDir+"AllPrjDB.mdb" " 改为 "basDirectory::DBShareDir"
CString strAllPrjDBPathName = basDirectory::DBShareDir + _T("AllPrjDB.mdb");//20071025 "ProjectDBDir" 改为 "DBShareDir"
//20071105 " basDirectory::DBShareDir+"DrawingSize.mdb" " 改为 " basDirectory::DBShareDir "
CString strsortPathName = basDirectory::DBShareDir + _T("DrawingSize.mdb");//20071025 "Sort.mdb" 改为 "DrawingSize.mdb"
CString strworkprjPathName = basDirectory::ProjectDir+"workprj.mdb" ;
lpstrAllPrjDBPathName=(LPTSTR)(LPCTSTR)(strAllPrjDBPathName);
lpstrsortPathName=(LPTSTR) (LPCTSTR) (strsortPathName);
lpstrworkprjPathName=(LPTSTR) (LPCTSTR) (strworkprjPathName);
if(dlg.ShowEngVolDlg(lpstrworkprjPathName,lpstrAllPrjDBPathName,lpstrsortPathName)==false)
{
return;
}
EDIBgbl::SelSpecID=dlg.m_SelSpecID;
EDIBgbl::SelPrjID=dlg.m_SelPrjID;
EDIBgbl::SelDsgnID=dlg.m_SelDsgnID;
EDIBgbl::SelHyID=dlg.m_SelHyID;
EDIBgbl::SelVlmID=dlg.m_SelVlmID;
EDIBgbl::SelJcdm=dlg.m_SelVlmCODE;
CMenu* men=this->GetMenu();
men->EnableMenuItem(0,MF_ENABLED);
//取卷中的有关信息
_RecordsetPtr selSVPtr;
selSVPtr.CreateInstance(__uuidof(Recordset));
CString strSQL;
CString str;
_variant_t key;
str.Format("%ld",(EDIBgbl::SelVlmID));
strSQL=("SELECT * FROM [Volume] WHERE volumeid="+str+"");
try
{
selSVPtr->Open(_bstr_t(strSQL),(IDispatch*)conPRJDB,adOpenStatic,adLockOptimistic,adCmdText);
key=selSVPtr->GetCollect("jcdm");
if(key.vt==VT_EMPTY)
{
EDIBgbl::SelJcdm="";
}
else
{
EDIBgbl::SelJcdm=key.bstrVal;
}
key=selSVPtr->GetCollect("jcmc");
if(key.vt==VT_EMPTY)
{
EDIBgbl::SelVlmName="";
}
else
{
EDIBgbl::SelVlmName=key.bstrVal;
}
}
catch(_com_error e)
{
AfxMessageBox(e.ErrorMessage());
return;
}
//取工程中的有关信息
strSQL="select * from Engin where enginid='"+EDIBgbl::SelPrjID+"'";
try
{
if(selSVPtr->State==adStateOpen)
{selSVPtr->Close();}
selSVPtr->Open(_bstr_t(strSQL),(IDispatch*)conPRJDB,adOpenStatic,adLockOptimistic,adCmdText);
key=selSVPtr->GetCollect("gcmc");
if(key.vt==VT_EMPTY)
{
EDIBgbl::SelPrjName="";
}
else
{
EDIBgbl::SelPrjName=key.bstrVal;
}
key=selSVPtr->GetCollect("e_gcmc");
if(key.vt==VT_EMPTY||key.vt==VT_NULL)
{
EDIBgbl::SelPrjEnglishName="";
}
else
{
EDIBgbl::SelPrjEnglishName=key.bstrVal;
}
key=selSVPtr->GetCollect("UnitNum");
EDIBgbl::giUnitNum=(key.vt==VT_EMPTY)?0:key.iVal;
}
catch(_com_error e)
{
AfxMessageBox(e.ErrorMessage());
return;
}
if(selSVPtr->State==adStateOpen)
{
selSVPtr->Close();
}
//取行业中的相关信息,设计阶段,专业的相关信息
CDaoRecordset DataCurrWork;
CDaoRecordset DataCategory;//行业
CDaoRecordset DataSpe;//专业
CDaoRecordset DataDsgn;//设计阶段
CString str_sjhyid;
str_sjhyid.Format("%ld",(EDIBgbl::SelHyID));
COleVariant tmpVar;
CString str_zyid;
str_zyid.Format("%ld",(EDIBgbl::SelSpecID));
try
{
//行业
DataCategory.m_pDatabase=&EDIBgbl::dbDSize;//20071027 "dbSORT" 改为 "dbDSize"
DataCategory.Open(dbOpenSnapshot,_T("SELECT * FROM DrawSize where sjhyid="+str_sjhyid+""));
DataCategory.GetFieldValue(_T("SJHYIndex"),tmpVar);
EDIBDB::SJHYIndex=vtoi(tmpVar);
//专业
DataSpe.m_pDatabase=&EDIBgbl::dbDSize;//20071027 "dbSORT" 改为 "dbDSize"
DataSpe.Open(dbOpenSnapshot,_T("select * from speciality where zyid="+str_zyid+""));
DataSpe.GetFieldValue(_T("ZYMC"),tmpVar);
EDIBgbl::SelSpecName = vtos(tmpVar);
DataSpe.GetFieldValue(_T("zydm"),tmpVar);
EDIBgbl::strSelSpec=vtos(tmpVar);
//设计阶段
DataDsgn.m_pDatabase=&EDIBgbl::dbDSize;//20071027 "dbSORT" 改为 "dbDSize"
CString strDsgn;
strDsgn.Format("%ld",(EDIBgbl::SelDsgnID));
DataDsgn.Open(dbOpenSnapshot,_T("select * from designstage where sjjdid="+strDsgn+""));
DataDsgn.GetFieldValue(_T("sjjdmc"),tmpVar);
EDIBgbl::SelDsgnName =vtos(tmpVar);
DataDsgn.GetFieldValue(_T("sjjddm"),tmpVar);
EDIBgbl::strSelDsgn=vtos(tmpVar);
//保存当的结果
DataCurrWork.m_pDatabase=&EDIBgbl::dbPRJ;
DataCurrWork.Open(dbOpenDynaset,_T("Select * From CurrentWork"));
CDaoRecordset * m_Rs;
m_Rs=&DataCurrWork;
m_Rs->Edit();
DataCategory.GetFieldValue(_T("sjhyid"),tmpVar);
m_Rs->SetFieldValue(_T("sjhyindex"),tmpVar);
DataCategory.GetFieldValue(_T("sjhy"),tmpVar);
m_Rs->SetFieldValue(_T("sjhy",),tmpVar);
DataDsgn.GetFieldValue(_T("sjjddm"),tmpVar);
m_Rs->SetFieldValue(_T("sjjddm"),tmpVar);
DataDsgn.GetFieldValue(_T("sjjdmc"),tmpVar);
m_Rs->SetFieldValue(_T("sjjdmc"),tmpVar);
DataSpe.GetFieldValue(_T("zydm"),tmpVar);
m_Rs->SetFieldValue(_T("zydm"),tmpVar);
DataSpe.GetFieldValue(_T("zymc"),tmpVar);
m_Rs->SetFieldValue(_T("zymc"),tmpVar);
m_Rs->Update();
}
catch(_com_error e)
{
AfxMessageBox(e.ErrorMessage());
return;
}
if( EDIBgbl::SelHyID < 0 ) EDIBgbl::SelHyID = modSelPDSV::defHyID;
if( EDIBDB::SJHYIndex < 0 ) EDIBDB::SJHYIndex = modSelPDSV::defSJHYIndex;
if( EDIBgbl::CompanyID == _T("") ) EDIBgbl::CompanyID = _T("43");
SetRegValue(_T("RecentWork"), user::gstrAppName + _T("_PrjID"), EDIBgbl::SelPrjID);
SetRegValue(_T("RecentWork"), user::gstrAppName + _T("_DsgnID"), EDIBgbl::SelDsgnID);
SetRegValue(_T("RecentWork"), user::gstrAppName + _T("_SpecID"), EDIBgbl::SelSpecID);
SetRegValue(_T("RecentWork"), user::gstrAppName + _T("_HyID"), EDIBgbl::SelHyID);
SetRegValue(_T("RecentWork"), user::gstrAppName + _T("_VlmID"), EDIBgbl::SelVlmID);
SetRegValue(_T("RecentWork"), user::gstrAppName + _T("_Dsgn"), EDIBgbl::strSelDsgn);
SetRegValue(_T("RecentWork"), user::gstrAppName + _T("_Spec"), EDIBgbl::strSelSpec);
SetRegValue(_T("RecentWork"), user::gstrAppName + _T("_BillID"), EDIBgbl::SelBillType);
SetRegValue(_T("RecentWork"), _T("SJHY"), EDIBDB::SJHY);
SetRegValue(_T("RecentWork"), _T("SJHYIndex"), EDIBDB::SJHYIndex);
EDIBgbl::InitDBTBN();
FrmPhsData.ShowWindow(SW_SHOW);
AfxGetApp()->EndWaitCursor();
CString ss=EDIBgbl::gsTitle+(EDIBgbl::TBNSelPrjSpec == _T("") ? _T("") : (_T(" ") + EDIBgbl::TBNSelPrjSpec + EDIBgbl::Btype[EDIBgbl::SelBillType] + _T(" (") + EDIBgbl::SelJcdm + _T(")")));
AfxGetApp()->m_pMainWnd->SetWindowText(ss);
FrmPhsData.SetWindowText(EDIBgbl::Cbtype[EDIBgbl::SelBillType].MnuCaption + " " + EDIBgbl::TBNSelPrjSpec + EDIBgbl::Btype[EDIBgbl::SelBillType] + " (" + EDIBgbl::SelJcdm + ")");//pfg20050303
}
void CMainFrame::OnSampleManage()
{
// TODO: Add your command handler code here
if (EDIBgbl::SelBillType != EDIBgbl::TZA)
return;
//选择模板之前必须处理数据,以便获得管径、荷载、温度等必要数据。
try
{
if(FrmTxsr.m_pViewTxsr->m_ActiveRs!=NULL && FrmTxsr.m_pViewTxsr->m_ActiveRs->State!=adStateClosed )
{
if(FrmTxsr.m_pViewTxsr->m_ActiveRs->adoEOF && FrmTxsr.m_pViewTxsr->m_ActiveRs->BOF)
return;
if( !FrmTxsr.m_pViewTxsr->m_ActiveRs->adoEOF && !FrmTxsr.m_pViewTxsr->m_ActiveRs->BOF)
FrmTxsr.m_pViewTxsr->m_ActiveRs->Update();
modPHScal::zdjh=vtoi(FrmTxsr.m_pViewTxsr->m_ActiveRs->GetCollect(_T("zdjh")));
modPHScal::iSelSampleID=vtoi(FrmTxsr.m_pViewTxsr->m_ActiveRs->GetCollect(_T("iSelSampleID")));
if(modPHScal::iSelSampleID<=0)
{
modPHScal::iSelSampleID=1;
FrmTxsr.m_pViewTxsr->m_ActiveRs->PutCollect(_T("iSelSampleID"),_variant_t((long)1));
FrmTxsr.m_pViewTxsr->m_ActiveRs->Update();
}
modPHScal::PreCalCrudeData(FrmPhsData.m_DataBillRs);
CSelTemplate dlg;
dlg.DoModal();
}
}
catch(_com_error e)
{
ShowMessage(e.Description());
}
}
void CMainFrame::OnInputSArec()
{
// TODO: Add your command handler code here
CFrmAddSArecord addDlg;
addDlg.DoModal();
FrmTxsr.m_pViewTxsr->m_PagOption->LoadSAG100();
}
void CMainFrame::OnCalcZdjh()
{
EDIBgbl::IsCalc=true;//正在计算
FrmTxsr.m_IsFirst=false;
if(EDIBgbl::SelBillType != EDIBgbl::TZA)
{
MessageBox(GetResStr(IDS_PleaseSelectTZA));
return;
}
if(!ModEncrypt::gbLegalUser)
{
CTime tm=CTime::GetCurrentTime();
if(tm.GetSecond()% 12 !=0)
{
//非法用户,只有1/8的时间可以计算
MessageBox(GetResStr(IDS_DemoVersionOutDate));
return;
}
}
try
{
if (FrmTxsr.m_pViewTxsr->m_ActiveRs->BOF || FrmTxsr.m_pViewTxsr->m_ActiveRs->adoEOF) return;
//第k个开始连续计算n个支吊架
AfxGetApp()->BeginWaitCursor();
if(FrmTxsr.m_pViewTxsr->m_bActive)
FrmTxsr.m_pViewTxsr->UpdateBoundData();
frmStatus.ShowWindow(SW_SHOW);
CString sTmp;
modPHScal::zdjh=vtoi(FrmTxsr.m_pViewTxsr->m_ActiveRs->GetCollect(_T("zdjh")));
sTmp.Format(_T("%d"),modPHScal::zdjh);
frmStatus.m_Label1.Format(GetResStr(IDS_CalculatingNoXphs),sTmp);// _T("正在计算") & zdjh & _T("号支吊架")
modPHScal::iSelSampleID=vtoi(FrmTxsr.m_pViewTxsr->m_ActiveRs->GetCollect(_T("iSelSampleID")));
sTmp.Format(_T("%d"),modPHScal::iSelSampleID);
frmStatus.m_Label2.Format(GetResStr(IDS_ApplyingSampleIDxPhs),sTmp);//_T("正在使用") & iSelSampleID & _T("号样本支吊架组合结构")
frmStatus.SetWindowText(GetResStr(IDS_PhsCalculation));//' _T("计算支吊架")
frmStatus.UpdateData(false);
frmStatus.UpdateStatus(0.02,true);
frmStatus.UpdateWindow();
modPHScal::VB_Cal(FrmTxsr.m_pViewTxsr->m_ActiveRs,modPHScal::zdjh,frmStatus);
frmStatus.UpdateWindow();
AfxGetApp()->EndWaitCursor();
frmStatus.ShowWindow(SW_HIDE);
AfxGetApp()->EndWaitCursor();
}
catch(CException *e)
{
e->Delete();
AfxGetApp()->EndWaitCursor();
frmStatus.ShowWindow(SW_HIDE);
}
catch(...)
{
AfxGetApp()->EndWaitCursor();
frmStatus.ShowWindow(SW_HIDE);
}
if(FrmDataEDIT.m_hWnd ==NULL) return;
if( FrmDataEDIT.m_hWnd == this->GetActiveWindow()->m_hWnd )
{
FrmDataEDIT.CloseWindow ();
FrmDataEDIT.DestroyWindow();
EDIBgbl::gbDisplayBOM = true;
FrmDataEDIT.m_bAllowUpd=true;
if(!IsWindow(FrmDataEDIT.m_hWnd))
{
FrmDataEDIT.Create(IDD_DATAEDIT,AfxGetApp()->m_pMainWnd);
FrmDataEDIT.UpdateWindow();
}
::SetWindowPos(FrmDataEDIT.GetSafeHwnd(),HWND_TOP,0,0,0,0,/*SWP_NOACTIVATE|*/SWP_NOSIZE|SWP_NOMOVE|SWP_SHOWWINDOW);
}
}
//-----------------------------------------------------------
// Function Name:OnDrawZdj
// Parameter(s) :void
// Return :void
// Memo :
// Author :WangJia
// Modify :在画图前后修改注册表中的值
//-----------------------------------------------------------
void CMainFrame::OnDrawZdj()
{
CString szGUID = _T("{5EFC7975-14BC-11CF-9B2B-00AA00573819}");
HANDLE hSem = CreateSemaphore( NULL, 1, 1, szGUID);
//////////////////////////////////////////////////////////////////////////
static long n=0;
try
{
CString sTmp,sTmp2;
modPHScal::zdjh=(long)FrmTxsr.m_pViewTxsr->m_ActiveRs->GetCollect(_T("zdjh"));
if(vtob(FrmTxsr.m_pViewTxsr->m_ActiveRs->GetCollect(_T("bCalSuccess")))==false)
{
CString strMsg;
strMsg.Format(IDS_NO_DRAWPHS,modPHScal::zdjh);
ShowMessage(strMsg);
::CloseHandle(hSem);
return;
}
modPHScal::iSelSampleID=(long)FrmTxsr.m_pViewTxsr->m_ActiveRs->GetCollect(_T("iSelSampleID"));
if(!EDIBAcad::StartAcad())
{
::CloseHandle(hSem);
return;
}
EDIBAcad::DisplayAcadTop();
//如果当前打开的图形不是(PhsBlkDir & _T("phs.dwg")),需要重新打开
//因为后面的操作需要大量的图形块准备好
basDirectory::PhsBlkDir.MakeUpper();
EDIBAcad::GetActiveAcadDoc();
modPHScal::SetBasePoint();
EDIBAcad::EraseAllEntities();
modPHScal::DrawPhs(FrmTxsr.m_pViewTxsr->m_ActiveRs);
if(modPHScal::gbAutoSaveDrawing)
{
sTmp=vtos(FrmTxsr.m_pViewTxsr->m_ActiveRs->GetCollect(_T("GN1")));
sTmp.MakeUpper();
if(sTmp!=_T("G100"))
DDEFileCmd(SaveDwg);
}
EDIBAcad::SetAcadTop();
}
catch(::CDaoException* e)
{
e->ReportError();
e->Delete();
}
catch(COleException* e)
{
e->ReportError();
e->Delete();
}
catch(_com_error e)
{
MessageBox(e.Description());
}
catch(CException *e)
{
e->Delete();
}
catch(...)
{
}
//////////////////////////////////////////////////////////////////////////
::CloseHandle(hSem);
}
long CMainFrame::GetMenuHeight()
{
CRect rc1,rc2;
this->GetWindowRect(&rc1);
this->GetClientRect(&rc2);
return rc1.Height()-rc2.Height() + ::GetSystemMetrics(SM_CYBORDER);
}
void CMainFrame::InitPos()
{
CRect rc1;
::SystemParametersInfo(SPI_GETWORKAREA,0,(LPVOID)&rc1,0);
this->SetWindowPos(NULL,0,0,rc1.Width(),GetMenuHeight(),SWP_NOZORDER|SWP_NOACTIVATE);
}
void CMainFrame::DDEFileCmd(DWORD cmd)
{
try
{
CString strTmp,strTmp2;
bool bExist=false;
switch(cmd)
{
case NewDwg:
EDIBAcad::StartAcad();
break;
case OpenDwg:
//打开当前支吊架图形,便于观察和打印绘制。如果图形不存在,打开phs.dwg。
modPHScal::gsDwgFN = modPHScal::GetSaveAsDwgFileName(modPHScal::zdjh);
if( modPHScal::gsDwgFN != _T("") )
{
//获取文件名成功,不为空
if( FileExists(modPHScal::gsDwgFN))
{
//文件存在
EDIBAcad::StartAcad(modPHScal::gsDwgFN);
modPHScal::giZDJHinDwg =(long) EDIBAcad::objAcadDoc.Invoke(_T("GetVariable"),1,&_variant_t(_T("USERI5")));
}
else
{
//文件不存在
EDIBAcad::StartAcad();
}
}
else
{
modPHScal::gsDwgFN = user::SelFileDwg(GetResStr(IDS_MsgBox_60573), basDirectory::ProjectDWGDir);
if( modPHScal::gsDwgFN != _T("") )
{
EDIBAcad::StartAcad(modPHScal::gsDwgFN);
modPHScal::giZDJHinDwg = (long)EDIBAcad::objAcadDoc.Invoke(_T("GetVariable"),1,&_variant_t(_T("USERI5")));
}
else
EDIBAcad::StartAcad();
}
break;
case SaveDwg:
case SaveAsDwg:
if( modPHScal::gsDwgFN != _T("") )
{
//pfg20050331
if((cmd==2)&&FileExists(modPHScal::gsDwgFN))
{
if(AfxMessageBox("警告:\n"+modPHScal::gsDwgFN+"文件已经存在,是否覆盖!",1)!=IDOK)
{
return;
}
else
{
bExist=true;
}
}
//必须首先把手工修改的图形保存到m.dxf文件中,因为写块时会丢失m_phs0层
EDIBAcad::AddEntities2SSetInLayers(acSelectionSetAll,1, _T("m_phs0"));
if(!DirExists(basDirectory::ProjectDWGDir))
if(!CreateDirectory(basDirectory::ProjectDWGDir,NULL))
return;
EDIBAcad::objAcadDoc=EDIBAcad::objAcadApp.GetPropertyByName(variant_t _T("ActiveDocument"));
strTmp=vtos(EDIBAcad::objAcadDoc.Invoke(_T("GetVariable"),1,&_variant_t(_T("DWGPREFIX"))));
strTmp2=vtos(EDIBAcad::objAcadDoc.Invoke(_T("GetVariable"),1,&_variant_t(_T("DWGNAME"))));
user::AddDirSep(strTmp);
strTmp.MakeUpper();
strTmp2.MakeUpper();
modPHScal::gsDwgFN.MakeUpper();
if(bExist&&modPHScal::gsDwgFN.Find(strTmp2)==-1)
{
try
{
CMObject docs,doc;
docs = EDIBAcad::objAcadApp.GetPropertyByName ( _T ( "Documents" ) );
long count = docs.GetPropertyByName( _T("Count") );
for ( long n = 0; n < count; n++ )
{
doc=(_variant_t)docs.Invoke("Item",1,&_variant_t(n));
CString str=vtos((_variant_t)doc.GetPropertyByName("FullName"));
if ( str.CollateNoCase (modPHScal::gsDwgFN) == 0 )
{
doc.Invoke(_T("Close"),0,&_variant_t());
break;
}
}
}
catch(CException *e)
{
e->Delete();
}
CFile::Remove(modPHScal::gsDwgFN);
}
EDIBAcad::objAcadDoc.Invoke(_T("SetVariable"),2,&_variant_t(_T("DWGNAME")),&_variant_t(modPHScal::gsDwgFN));
if(strTmp+strTmp2 == modPHScal::gsDwgFN)
{
EDIBAcad::objAcadDoc.Invoke0(_T("Save"));
}
else
{//2004.08.11由杨武辉改造完成以后,
//存盘支吊架图形变得简单了。added by ligb on 2004.08.11
EDIBAcad::objAcadDoc.Invoke(_T("SaveAs"),1, &_variant_t(modPHScal::gsDwgFN));
AddRecentFiles(modPHScal::gsDwgFN);
LoadRecentFiles();
}
}
break;
case SaveAsSampleDwg:
{
CString sSampleDwg,sTmp;
sTmp.Format(_T("%4d"),modPHScal::iSelSampleID);
sSampleDwg = basDirectory::TemplateDir + sTmp + _T(".dwg");
EDIBAcad::AddEntities2SSetInLayers(acSelectionSetAll,5, _T("bom"), _T("dim"), _T("phs"), _T("tag"), _T("tk"));
if (FileExists(sSampleDwg) )
{
if(MessageBox(GetResStr(IDS_MsgBox_60574) + sSampleDwg + GetResStr(IDS_MsgBox_60575), NULL,MB_ICONQUESTION|MB_DEFBUTTON1|MB_YESNO|MB_SYSTEMMODAL)==IDYES)
EDIBAcad::objAcadDoc.Invoke(_T("Wblock"),2,&_variant_t(sSampleDwg), &_variant_t(EDIBAcad::sset.p));
}
else
EDIBAcad::objAcadDoc.Invoke(_T("Wblock"),2,&_variant_t(sSampleDwg), &_variant_t(EDIBAcad::sset.p));
}
break;
case OutPutPhsBlock:
EDIBAcad::WblockFromPhsToPhsBlkDir(basDirectory::ProjectDir);
}
}
catch(CException *e)
{
e->Delete();
}
catch(...)
{
}
}
void CMainFrame::OnStartacad()
{
// TODO: Add your command handler code here
EDIBAcad::StartAcad();
}
void CMainFrame::OnSelPreferences()
{
// TODO: Add your command handler code here
ShowModalSelSpecification(FALSE);
//EDIBgbl::InitPhsStructureREFandName();
}
void CMainFrame::OnFileOpt()
{
// TODO: Add your command handler code here
CFrmPreferences dd;
dd.DoModal();
}
void CMainFrame::OnIntImpdata()
{
// TODO: Add your command handler code here
CFrmDatabaseIn dd;
dd.DoModal();
}
void CMainFrame::OnSetTableFormat()
{
// TODO: Add your command handler code here
CDlgDataFormatDll dlgFormat;
//显示对话框之前,必须对其指定数据库的全路径名。
LPTSTR lpstrDB;
CString strDB;
strDB=basDirectory::DBShareDir;//20071016"sort.mdb"改为"TableFormat.mdb" //20071024 "ProjectDBDir" 改为 "DBShareDir"
lpstrDB=(LPTSTR) (LPCTSTR) strDB;
dlgFormat.ShowFormatDlg(lpstrDB);
}
void CMainFrame::SumCL(int Index)
{
AfxGetApp()->BeginWaitCursor();
USES_CONVERSION;
try
{
if(!FrmTxsr.m_pViewTxsr->m_ActiveRs->adoEOF && !FrmTxsr.m_pViewTxsr->m_ActiveRs->BOF)
//表格窗口失去焦点,更新当前支吊架号
modPHScal::zdjh=vtoi(FrmTxsr.m_pViewTxsr->m_ActiveRs->GetCollect(_T("Zdjh")));
static bool bExcelStart =false; //Excel已经启动
double X =0;long i=0;
CString strTbn, strXls;
CDaoDatabase db;
CDaoRecordset rs ;
_RecordsetPtr rs1;
CString BOM_Format_phs;
if( !ModEncrypt::gbLegalUser )
{
ShowMessage(GetResStr(IDS_IllegalUserOrDemoVerCantOutPutBom));
return;
}
CString strTmp;
//判断是否所有支吊架计算完成。
try
{
if(!FrmTxsr.m_pViewTxsr->m_ActiveRs->adoEOF && !FrmTxsr.m_pViewTxsr->m_ActiveRs->BOF)
FrmTxsr.m_pViewTxsr->m_ActiveRs->Update();
}
catch(CException *e)
{
e->Delete();
}
catch(...)
{
}
CString SQLx = _T("SELECT count(*) FROM [") + EDIBgbl::Btype[EDIBgbl::TZA] + _T("] WHERE ( bCalSuccess=0 OR bCalSuccess IS NULL )");
if( modPHScal::gbSumAllVolume )
{
SQLx +=_T(" AND VolumeID IN ( SELECT VolumeID FROM Volume WHERE EnginID=\'") + EDIBgbl::SelPrjID + _T("\' AND ZYID = ") + ltos(EDIBgbl::SelSpecID) + _T(" AND SJJDID = ") + ltos(EDIBgbl::SelDsgnID) + _T(" AND SJHYID = ") + ltos(EDIBgbl::SelHyID) +_T(") ");
}
else
{
SQLx +=_T(" AND VolumeID =") + ltos(EDIBgbl::SelVlmID);
}
long i1,i2;
rs1.CreateInstance(__uuidof(Recordset));
rs1->Open(_variant_t(SQLx),(IDispatch*)::conPRJDB,adOpenForwardOnly,adLockReadOnly,adCmdText);
i1=vtoi(rs1->GetCollect(_variant_t((long)0)));
rs1->Close();
SQLx = _T("SELECT count(*) FROM [") + EDIBgbl::Btype[EDIBgbl::TZA] + _T("] WHERE ");
if(modPHScal::gbSumAllVolume )
{
SQLx +=_T(" VolumeID IN ( SELECT VolumeID FROM Volume WHERE EnginID=\'") + EDIBgbl::SelPrjID + _T("\' AND ZYID = ") + ltos(EDIBgbl::SelSpecID) + _T(" AND SJJDID = ") + ltos(EDIBgbl::SelDsgnID) + _T(" AND SJHYID = ") + ltos(EDIBgbl::SelHyID) +_T(") ");
}
else
{
SQLx +=_T(" VolumeID =") + ltos(EDIBgbl::SelVlmID);
}
rs1->Open(_variant_t(SQLx),(IDispatch*)::conPRJDB,adOpenForwardOnly,adLockReadOnly,adCmdText);
i2=vtoi(rs1->GetCollect(_variant_t((long)0)));
rs1->Close();
rs1=NULL;
strTmp.Format(GetResStr(IDS_SomePhsNotCalSuccess),ltos(i2),ltos(i2-i1),ltos(i1));
if( IDNO == ShowMessage(strTmp,MB_DEFBUTTON1|MB_ICONQUESTION|MB_YESNO) )
return;
CMObject objTmp;
CCadPoint p0,p1;
//生成所有或某个卷册的材料汇总表
Cavphs->GetphsSumBom();
CString strTmp2;
BOOL flag = true;
switch(Index)
{
case 0:
case 1:
//如果当前打开的图形不是(PhsBlkDir + _T("phs.dwg")),需要重新打开
//因为后面的操作需要大量的图形块准备好
if(EDIBAcad::objAcadApp.GetActiveObject(EDIBAcad::gstrApplicatonName)!=S_OK)
flag = EDIBAcad::StartAcad();
else
{
EDIBAcad::gsACADVER=vtos(EDIBAcad::objAcadApp.GetPropertyByName("Version"));
if(EDIBAcad::gsACADVER.Left(2)==_T("14"))
{
EDIBAcad::gbACADR14 = true;
}
else
{
EDIBAcad::gbACADR14 = false;
}
}
if(flag == FALSE)
break;
EDIBAcad::GetActiveAcadDoc();
BOM_Format_phs = _T("ACAD");
//下句接受材料汇总表起始图号,但程序目前实际未采用该值
EDIBgbl::gStartPage = modPHScal::iBOMStartNo();
EDIBDB::DrawID = EDIBAcad::GetDrawIDAndName(modPHScal::zdjh + modPHScal::glDrawNoStartNumber - 1, EDIBDB::DrawName);
ShowMessage(GetResStr(IDS_PleasePickApointAsBOMInsertPointINAutoCAD));
EDIBAcad::SetAcadTop();
//传递正确的格式参数
BOM_Format_phs = _T(";");
EDIBDB::OutPutTable(_T("tmpPhsBOM1"), EDIBgbl::dbPRJ.GetName(), _T(""), EDIBgbl::dbPRJ, _T("tmp2"), BOM_Format_phs);
//对tmpPhsBOM1表编号
SQLx = _T("SELECT sum(CLzz) as SumWeight FROM tmpPhsBOM1");
rs.m_pDatabase=&EDIBgbl::dbPRJ;rs.Open(dbOpenSnapshot,SQLx);
if( rs.IsEOF() && rs.IsBOF() ){
rs.Close();
}else {
EDIBgbl::gsngSumBomWeight = vtof(GetFields(rs,_T("SumWeight")));
SQLx = _T("SELECT * FROM tmpPhsBOM1");
rs.Close();
rs.m_pDatabase=&EDIBgbl::dbPRJ;
rs.Open(dbOpenDynaset,SQLx);
i=0;
//============汇总电焊条==============
if( modPHScal::g_bDHT )
{
rs.AddNew();
rs.SetFieldValue("CLmc",STR_VAR("电焊条"));
rs.SetFieldValue("CLgg",STR_VAR(modPHScal::g_strDHTGG));
rs.Update();
rs.Close();
rs.Open(dbOpenDynaset,SQLx);
}
//====================================
while(!rs.IsEOF())
{
i++;
rs.Edit();rs.SetFieldValue(_T("SEQ"),COleVariant((long)i)); rs.Update();
rs.MoveNext();
}
rs.Close();
rs.Open(dbOpenSnapshot,_T("SELECT * FROM TmpPhsBOM1"));
if(i>0)
{
if( EDIBAcad::gbACADR14 || !bIsCom ) //使用动态库画图 zsy 12/30
{
rs.Close();
}else
{
objTmp=EDIBAcad::objAcadDoc.GetPropertyByName(variant_t _T("Utility"));
p0 = objTmp.Invoke(_T("GetPoint"),2,(LPVARIANT)p1,&_variant_t(GetResStr(IDS_PleasePickApointAsBOMInsertPointINAutoCAD)));
} //12/30
EDIBAcad::DrawTableACAD(p0, (Index == 0 ? EDIBgbl::TCL : EDIBgbl::TCLA4), atan(1) * 0, rs, 1.0f);
}
}
rs.Close();
EDIBAcad::SetAcadNoTop();
break;
case 2:
{
EDIBDB::CloseExcel();
BOM_Format_phs = _T("Excel 5.0;");
strXls = basDirectory::ProjectDir + _T("phsBom") + EDIBgbl::SelPrjID + _T(".xls");
if( FileExists(strXls) )
{
::DeleteFile( strXls );
}
if( !FileExists(strXls) )
{
if( FileExists(basDirectory::TemplateDir+_T("phsBomF4511.xls")) )
{
CopyFile(basDirectory::TemplateDir+_T("phsBomF4511.xls"),strXls,TRUE);
}
else
{
CString strInfo;
strInfo.Format(IDS_NOTEXIST_EXCELFILE,basDirectory::TemplateDir,_T("phsBomF4511.xls"));
AfxMessageBox(strInfo);
AfxGetApp()->EndWaitCursor();
return;
}
}
CDaoRecordset rs1;
CString strPaintPathName, strTblName;
SQLx = _T("SELECT BomIndex, BomName , BomTable FROM BOMname ORDER BY BomIndex");
rs.m_pDatabase=&EDIBgbl::dbPHScode;rs.Open(dbOpenSnapshot,SQLx);//20071101 "dbSORT" 改为 "dbPHScode"
if( rs.IsEOF() && rs.IsBOF() )
{
}
else
{
int iBomIndex;
while(!rs.IsEOF())
{
if( FileExists(strXls) )
{
db.Open(strXls,FALSE,FALSE,BOM_Format_phs);
strTbn = vtos(rs.GetFieldValue("BomName"));
if( EDIBgbl::tdfExists(db, strTbn) )
{
db.Execute(_T("DROP TABLE ") + strTbn);
db.CanUpdate();
}
db.Close();
}
i = 0;
SQLx = _T("SELECT sum(CLzz) as SumWeight FROM tmp") + vtos(GetFields(rs,_T("BomTable")));
rs1.m_pDatabase=&EDIBgbl::dbPRJ;
rs1.Open(dbOpenSnapshot,SQLx);
if( rs1.IsEOF() && rs1.IsBOF() )
{
rs1.Close();
}
else
{
EDIBgbl::gsngSumBomWeight = vtof(GetFields(rs1,_T("SumWeight")));//, 0, rs1.Fields(_T("SumWeight")))
SQLx = _T("SELECT SEQ FROM tmp") + vtos(GetFields(rs,_T("BomTable")));
rs1.Close();
rs1.m_pDatabase=&EDIBgbl::dbPRJ;
rs1.Open(dbOpenDynaset,SQLx);
if( rs1.IsEOF() && rs1.IsBOF() )
{
}
else
{
while(!rs1.IsEOF())
{
i++;
rs1.Edit();rs1.SetFieldValue(_T("SEQ"),COleVariant((long)i)); rs1.Update();
rs1.MoveNext();
}
}
rs1.Close();
//获得表类型,与保温油漆软件AutoIPED接口时,
//只有3(管部汇总表),4(型钢零件汇总表用于下料),6(连接件汇总表用于制作),8(附件汇总表),9(螺栓螺母汇总表).须要处理.
iBomIndex = vtoi(rs.GetFieldValue("BomIndex"));
if( !EDIBgbl::strExportPaint.IsEmpty() )
{
//重新写入到一个Excel文件中.
switch( iBomIndex )
{
case 3:
case 4:
case 6:
case 8:
case 9:
//strTblName = "paint";
// strPaintPathName = basDirectory::ProjectDir + strTblName + ".xls";
EDIBDB::CreateTableToAutoIPED(strPaintPathName, strTblName, strTbn, EDIBgbl::gsngSumBomWeight);
break;
}
}
}
EDIBDB::OutPutTable(strTbn, strXls, BOM_Format_phs, EDIBgbl::dbPRJ, _T("tmp") + vtos(GetFields(rs,_T("BomTable"))), BOM_Format_phs);
rs.MoveNext();
}
}
if( EDIBgbl::strExportPaint.IsEmpty() ) //导出数据到AutoIPED也调用该函数,但不要显示下面对话框.
{
//如果Excel未启动,才调用这过程。以避免错误。
if( ShowMessage(GetResStr(IDS_DoYouWantViewBomXls),MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON1)==IDYES)
{
EDIBDB::StartEXCEL(strXls);
}
}
else
{ //记住该Excel文件的路径,进行导出.之后再清空.
EDIBgbl::strExportPaint = strPaintPathName;
}
}
break;
case 3:
BOM_Format_phs = _T("Text;");
if( FileExists(basDirectory::ProjectDBDir + _T("phs.txt")) ){
DeleteFile(basDirectory::ProjectDBDir + _T("phs.txt"));
}
EDIBDB::OutPutTable(_T("Phs.txt"), basDirectory::ProjectDBDir, BOM_Format_phs, EDIBgbl::dbPRJ, _T("tmp2"), BOM_Format_phs);
::WinExec(T2A((LPTSTR)(LPCTSTR)(user::gstrWinDir+_T("notepad.exe ")+basDirectory::ProjectDBDir+_T("phs.txt"))),SW_SHOW);
break;
case 4:
//生成正规的Excel汇总表
BOM_Format_phs = _T(";");
EDIBDB::DrawID = EDIBAcad::GetDrawIDAndName(modPHScal::zdjh + modPHScal::glDrawNoStartNumber - 1, EDIBDB::DrawName);
EDIBDB::OutPutTable(_T("tmpPhsBOM1"), EDIBgbl::dbPRJ.GetName(), _T(""), EDIBgbl::dbPRJ, _T("tmp2"), BOM_Format_phs);
//对tmpPhsBOM1表编号
SQLx = _T("SELECT sum(CLzz) as SumWeight FROM tmpPhsBOM1");
rs.m_pDatabase=&EDIBgbl::dbPRJ;rs.Open(dbOpenSnapshot,SQLx);
if( rs.IsEOF() && rs.IsBOF() ){
rs.Close();
}else {
EDIBgbl::gsngSumBomWeight = vtof(GetFields(rs,_T("SumWeight")));
SQLx = _T("SELECT * FROM tmpPhsBOM1");
rs.Close();
rs.m_pDatabase=&EDIBgbl::dbPRJ;rs.Open(dbOpenDynaset,SQLx);
i=0;
while(!rs.IsEOF())
{
i++;
rs.Edit();rs.SetFieldValue(_T("SEQ"),COleVariant((long)i)); rs.Update();
rs.MoveNext();
}
rs.Close();
rs.Open(dbOpenSnapshot,_T("SELECT * FROM TmpPhsBOM1"));
if(i>0)
EDIBAcad::DrawTableExcel(EDIBgbl::TCLE,rs);
}
//Excel用到rs记录集,当Excel没有关闭之前,关闭rs则Excel不能显示rs记录集
break;
}
}
catch(::CDaoException * e)
{
e->ReportError();
e->Delete();
}
catch(_com_error e)
{
ShowMessage(e.Description());
}
AfxGetApp()->EndWaitCursor();
}
void CMainFrame::OnSumAcad()
{
// TODO: Add your command handler code here
SumCL(0);
}
void CMainFrame::OnSumExc()
{
// TODO: Add your command handler code here
SumCL(2);
}
void CMainFrame::OnSumTxt()
{
// TODO: Add your command handler code here
SumCL(3);
}
void CMainFrame::OnSumAcad2()
{
// TODO: Add your command handler code here
SumCL(1);
}
void CMainFrame::OnIntPipeana()
{
// TODO: Add your command handler code here
try
{
if(EDIBgbl::SelBillType!=EDIBgbl::TZA)
return;
FrmPhsData.ShowWindow(SW_HIDE);
FrmTxsr.ShowWindow(SW_HIDE);
ReadYljsResult(FrmTxsr.m_pViewTxsr->m_ActiveRs);
FrmPhsData.ShowWindow(SW_SHOWNORMAL);
}
catch(CException *e)
{
e->Delete();
}
catch(...)
{
}
}
void CMainFrame::OnFileSelDir()
{
// TODO: Add your command handler code here
CFrmFolderLocation dlg;
dlg.DoModal();
}
void CMainFrame::OnFileOpen()
{
// TODO: Add your command handler code here
this->DDEFileCmd(1);
}
void CMainFrame::OnFileSave()
{
// TODO: Add your command handler code here
DDEFileCmd(2);
}
void CMainFrame::OnFileSaveAs()
{
// TODO: Add your command handler code here
DDEFileCmd(3);
}
void CMainFrame::OnFileCloseAcad()
{
// TODO: Add your command handler code here
if(ShowMessage(GetResStr(IDS_ReallyCloseACAD), MB_DEFBUTTON1|MB_ICONQUESTION|MB_YESNO) == IDYES)
{
if(EDIBAcad::objAcadApp.GetActiveObject(EDIBAcad::gstrApplicatonName) == S_OK)
EDIBAcad::objAcadApp.Invoke0(_T("Quit"));
modPHScal::gsDwgFN = _T("");
}
}
void CMainFrame::OnUpdateFileSave(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
if(modPHScal::gsDwgFN==_T(""))
{
pCmdUI->Enable(FALSE);
}
else
{
pCmdUI->Enable(::ModEncrypt::gbLegalUser);
}
}
void CMainFrame::OnUpdateFileNewOpen(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->Enable(::ModEncrypt::gbLegalUser);
}
void CMainFrame::OnCalAllzdj()
{
if(EDIBgbl::SelBillType != EDIBgbl::TZA)
{
MessageBox(GetResStr(IDS_PleaseSelectTZA));
return;
}
if(!ModEncrypt::gbLegalUser)
{
CTime tm=CTime::GetCurrentTime();
if(tm.GetSecond()% 12 !=0)
{
//非法用户,只有1/8的时间可以计算
MessageBox(GetResStr(IDS_DemoVersionOutDate));
return;
}
}
CStatusBarThread* thr=NULL;
try
{
int k,n,i=0;//第k个开始连续计算n个支吊架
CString sTmp;
if(FrmTxsr.m_pViewTxsr->m_bActive)
FrmTxsr.m_pViewTxsr->UpdateBoundData();
CInputBox dlg;
dlg.m_strTitle=GetResStr(IDS_FIRST_PHS);
dlg.m_strWndText=GetResStr(IDS_INPUT_FROM_K_PHS);
dlg.m_strValue.Format(_T("%d"),(long)FrmTxsr.m_pViewTxsr->m_ActiveRs->GetCollect(_T("zdjh")));
if( dlg.DoModal() == IDCANCEL )
return;
while(dlg.m_strValue==_T("") || dlg.m_strValue.GetAt(0) < _T('0') || dlg.m_strValue.GetAt(0) > _T('9'))
{
if( dlg.DoModal() == IDCANCEL )
return;
}
k=_ttoi(dlg.m_strValue);
dlg.m_strTitle.LoadString(IDS_CON_COUNT_PHS_AMOUT);
//_T("请输入从第%s个支吊架开始,连续计算的支吊架个数n")
//dlg.m_strWndText=_T("请输入从第") + ltos(k) + _T("个支吊架开始,连续计算的支吊架个数n");
dlg.m_strWndText.Format(IDS_INPUT_FROM_K_PHS_CON_COUNT_PHS_AMOUT,k);
dlg.m_strValue.Format(_T("%d"),FrmTxsr.m_pViewTxsr->m_ActiveRs->RecordCount- k+1);
if( dlg.DoModal() == IDCANCEL )
return;
while(dlg.m_strValue==_T("") || dlg.m_strValue.GetAt(0) < _T('0') || dlg.m_strValue.GetAt(0) > _T('9'))
{
if( dlg.DoModal() == IDCANCEL )
return;
}
n=_ttoi(dlg.m_strValue);
FrmTxsr.m_pViewTxsr->m_ActiveRs->MoveFirst();
FrmTxsr.m_pViewTxsr->m_ActiveRs->Find(_bstr_t(CString(_T("zdjh="))+ltos(k)),0,adSearchForward);
//FrmTxsr.m_pViewTxsr->m_ActiveRs->Find (_T("zdjh=") + ltos(k));
modPHScal::gbCalAllPhs=true;
modPHScal::gbStopCalAllPHS = false;
hStatusStopEvent=::CreateEvent(NULL,FALSE,FALSE,NULL);
hStatusCreateEvent=::CreateEvent(NULL,FALSE,FALSE,NULL);
thr=(CStatusBarThread*)::AfxBeginThread(RUNTIME_CLASS(CStatusBarThread));
::WaitForSingleObject(hStatusCreateEvent,INFINITE);
sTmp.Format(_T("%d"),modPHScal::zdjh);
CString sl1,sl2;
sl1.Format(GetResStr(IDS_CalculatingNoXphs),sTmp); // _T("正在计算") & zdjh & _T("号支吊架")
sl2.Format(GetResStr(IDS_ApplyingSampleIDxPhs), ltos(modPHScal::iSelSampleID)); //_T("正在使用") & iSelSampleID & _T("号样本支吊架组合结构")
thr->m_StatusBar.SetWindowText(GetResStr(IDS_AllPhsCalculation)); // _T("计算全部支吊架")
thr->m_StatusBar.m_ctrLabel1.SetWindowText(sl1);
thr->m_StatusBar.m_ctrLabel2.SetWindowText(sl2);
//thr->m_StatusBar.UpdateData(false);
thr->m_StatusBar.UpdateStatus(0.0,true);
// ::AfxBeginThread((AFX_THREADPROC)CalAllZdjh,this);
//EnableWindow(FALSE);
while (!FrmTxsr.m_pViewTxsr->m_ActiveRs->adoEOF && ( i < n))
{
i++;
modPHScal::zdjh=vtoi(FrmTxsr.m_pViewTxsr->m_ActiveRs->GetCollect(_T("zdjh")));
sTmp.Format (_T("%d"),modPHScal::zdjh);
sl1.Format (GetResStr(IDS_CalculatingNoXphs),sTmp); // _T("正在计算") & zdjh & _T("号支吊架")
modPHScal::iSelSampleID=vtoi(FrmTxsr.m_pViewTxsr->m_ActiveRs->GetCollect(_T("iSelSampleID")));
sl2.Format (GetResStr(IDS_ApplyingSampleIDxPhs), ltos(modPHScal::iSelSampleID)); //_T("正在使用") & iSelSampleID & _T("号样本支吊架组合结构")
thr->m_StatusBar.SetWindowText(GetResStr(IDS_AllPhsCalculation)); // _T("计算全部支吊架")
thr->m_StatusBar.m_ctrLabel1.SetWindowText(sl1);
thr->m_StatusBar.m_ctrLabel2.SetWindowText(sl2);
//thr->m_StatusBar.UpdateData(false);
thr->m_StatusBar.UpdateStatus(i / n,true);
if(::WaitForSingleObject(hStatusStopEvent,0)==WAIT_OBJECT_0)
{
modPHScal::gbStopCalAllPHS=true;
break;
}
modPHScal::VB_Cal(FrmTxsr.m_pViewTxsr->m_ActiveRs ,modPHScal::zdjh,thr->m_StatusBar);
FrmTxsr.m_pViewTxsr->m_ActiveRs->MoveNext();
//SetWindowTop Me.hwnd
}
if(FrmTxsr.m_pViewTxsr->m_ActiveRs->adoEOF )
{
FrmTxsr.m_pViewTxsr->m_ActiveRs->MoveLast();
modPHScal::zdjh=vtoi(FrmTxsr.m_pViewTxsr->m_ActiveRs->GetCollect(_T("zdjh")));
modPHScal::iSelSampleID=vtoi(FrmTxsr.m_pViewTxsr->m_ActiveRs->GetCollect(_T("iSelSampleID")));
}
//EnableWindow(TRUE);
modPHScal::gbCalAllPhs = false;
ShowMessage(GetResStr(IDS_AllPhsCalculationFinished)); //_T("所有支吊架计算完毕!")
}
catch(CException *e)
{
e->Delete();
}
catch(...)
{
}
if(thr!=NULL)
{
//::SendMessage(thr->m_StatusBar.GetSafeHwnd(),WM_CLOSEWINDOW1,0,0);
thr->EndThread();
::CloseHandle(hStatusCreateEvent);
::CloseHandle(hStatusStopEvent);
hStatusStopEvent=NULL;
hStatusCreateEvent=NULL;
}
}
LRESULT CALLBACK CalAllZdjhProc()
{
return 0;
}
void CMainFrame::OnFileCloseExcel()
{
// TODO: Add your command handler code here
EDIBDB::CloseExcel();
}
void CMainFrame::OnDrawZdjTab180()
{
// TODO: Add your command handler code here
DrawZdjTab(iZDJDRAW180mm);
}
void CMainFrame::DrawZdjTab(int index)
{
try
{
bool Found=false;
// bool bIsCom = false; //画图时用COM画为true; arx画为false; 1/12 zsy
CCadPoint p0, p1;
CDaoRecordset rs;
_RecordsetPtr rs1;
int i=0;
int k=0;
static int n=0;
if(index!=iZDJDRAWEXECL && index!=iZDJDRAWCatalogueExcel)
{
EDIBAcad::StartAcad();
EDIBAcad::DisplayAcadTop();
EDIBAcad::SetAcadTop();
EDIBAcad::GetActiveAcadDoc();
}
//如果当前打开的图形不是(PhsBlkDir & _T("phs.dwg")),需要重新打开
//因为后面的操作需要大量的图形块准备好
CString sTmp,sTmp1;
_variant_t vTmp;
/*if( LCase(objAcadDoc.GetVariable(_T("DWGPREFIX"))) = LCase(PhsBlkDir) And LCase(objAcadDoc.GetVariable(_T("DWGNAME"))) = _T("phs.dwg") ){
}else {
objAcadDoc.Open (PhsBlkDir & _T("phs.dwg"))
}*/
//CDaoRecordset rsTmp;
CMObject objTmp;
CCadPoint pTmp;
CString SQLx;
COleVariant varTmp;
_variant_t varNull;
varNull.ChangeType(VT_NULL);
if(index!=iZDJDRAWTag && index!=iZDJDRAWbom)
{
//判断是否所有支吊架计算完成。
try
{
if(!FrmTxsr.m_pViewTxsr->m_ActiveRs->adoEOF && !FrmTxsr.m_pViewTxsr->m_ActiveRs->BOF)
FrmTxsr.m_pViewTxsr->m_ActiveRs->Update();
}
catch(CException *e)
{
e->Delete();
}
catch(...)
{
}
CString SQLx = _T("SELECT count(*) FROM [") + EDIBgbl::Btype[EDIBgbl::TZA] + _T("] WHERE ( bCalSuccess=0 OR bCalSuccess IS NULL )");
if(modPHScal::gbSumAllVolume )
{
SQLx +=_T(" AND VolumeID IN ( SELECT VolumeID FROM Volume WHERE EnginID=\'") + EDIBgbl::SelPrjID + _T("\' AND ZYID = ") + ltos(EDIBgbl::SelSpecID) + _T(" AND SJJDID = ") + ltos(EDIBgbl::SelDsgnID) + _T(" AND SJHYID = ") + ltos(EDIBgbl::SelHyID) +_T(") ");
}
else
{
SQLx +=_T(" AND VolumeID =") + ltos(EDIBgbl::SelVlmID);
}
long i1,i2;
rs1.CreateInstance(__uuidof(Recordset));
rs1->Open(_variant_t(SQLx),(IDispatch*)::conPRJDB,adOpenForwardOnly,adLockReadOnly,adCmdText);
i1=vtoi(rs1->GetCollect(_variant_t((long)0)));
rs1->Close();
SQLx = _T("SELECT count(*) FROM [") + EDIBgbl::Btype[EDIBgbl::TZA] + _T("] WHERE ");
if(modPHScal::gbSumAllVolume )
{
SQLx +=_T(" VolumeID IN ( SELECT VolumeID FROM Volume WHERE EnginID=\'") + EDIBgbl::SelPrjID + _T("\' AND ZYID = ") + ltos(EDIBgbl::SelSpecID) + _T(" AND SJJDID = ") + ltos(EDIBgbl::SelDsgnID) + _T(" AND SJHYID = ") + ltos(EDIBgbl::SelHyID) +_T(") ");
}
else
{
SQLx +=_T(" VolumeID =") + ltos(EDIBgbl::SelVlmID);
}
rs1->Open(_variant_t(SQLx),(IDispatch*)::conPRJDB,adOpenForwardOnly,adLockReadOnly,adCmdText);
i2=vtoi(rs1->GetCollect(_variant_t((long)0)));
rs1->Close();
rs1=NULL;
CString strTmp;
strTmp.Format(GetResStr(IDS_SomePhsNotCalSuccess),ltos(i2),ltos(i2-i1),ltos(i1));
if( IDNO == ShowMessage(strTmp,MB_DEFBUTTON1|MB_ICONQUESTION|MB_YESNO) )
return;
}
switch(index)
{
case iZDJDRAWTag:
//EDIBAcad::DrawTagByPickEntity();
break;
case iZDJDRAWbom:
modPHScal::SetBasePoint();
Cavphs->GetphsSEQ(FrmTxsr.m_pViewTxsr->m_ActiveRs);
EDIBDB::MakeTmp2ToBom();
p0.SetPoint(modPHScal::pt2x,modPHScal::pt2y);
EDIBAcad::DeleteAllEntitiesInLayers(1,_T("bom"));
rs.m_pDatabase=&EDIBgbl::dbPRJ;
rs.Open(dbOpenSnapshot,_T("SELECT * FROM TMP2"));
EDIBAcad::DrawTableACAD(p0, EDIBgbl::TLJ, atan(1.0) * 0.0, rs,0,1.0f,_T("Bom"),_T("Bom"),_T("%g"),modPHScal::iAlignLjmx);
sTmp.Format(GetResStr(IDS_xDrawingFinished),EDIBgbl::Cbtype[EDIBgbl::TCL].MnuCaption);
ShowMessage(sTmp);
break;
case iZDJDRAWbomBJBW:
modPHScal::SetBasePoint();
Cavphs->GetphsSEQ(FrmTxsr.m_pViewTxsr->m_ActiveRs);
EDIBDB::MakeTmp2ToBom();
p0.SetPoint(modPHScal::pt2x,modPHScal::pt2y);
EDIBAcad::DeleteAllEntitiesInLayers(1,_T("bom"));
rs.m_pDatabase=&EDIBgbl::dbPRJ;
rs.Open(dbOpenSnapshot,_T("SELECT * FROM TMP2"));
EDIBAcad::DrawTableACAD(p0, EDIBgbl::TLJ_BJBW, atan(1.0) * 0.0, rs,0,1.0f,_T("Bom"),_T("Bom"),_T("%g"),modPHScal::iAlignLjmx);
sTmp.Format(GetResStr(IDS_xDrawingFinished),EDIBgbl::Cbtype[EDIBgbl::TCL].MnuCaption);
ShowMessage(sTmp);
break;
case iZDJDRAWload:
modPHScal::SetBasePoint();
modPHScal::PhsDisplacementLoadINFOMake();
break;
case iZDJDRAW270mm:
//每次计算一个支吊架时生成当前当前支吊架一览表,计算完成后总的一览表就生成了。
//每次计算一个支吊架时生成当前当前支吊架明细一览表,计算完成后总的明细一览表就生成了。
SQLx = _T("SELECT * FROM [") + EDIBgbl::Btype[EDIBgbl::TZD] + _T("] WHERE VolumeID=") + ltos(EDIBgbl::SelVlmID) + _T(" ORDER BY zdjh");
rs.m_pDatabase=&EDIBgbl::dbPRJDB;
rs.Open(dbOpenSnapshot,SQLx);
if(!rs.IsBOF() && !rs.IsEOF())
{//zsy 12/17 改为用ARX画图
ShowMessage(GetResStr(IDS_PleasePickApointAsZDJYLBInsertPointINAutoCAD));
if( EDIBAcad::gbACADR14 || !bIsCom ) //使用动态库画图
{
rs.Close();
}else
{
objTmp=EDIBAcad::objAcadDoc.GetPropertyByName(variant_t _T("Utility"));
p1=objTmp.Invoke(_T("GetPoint"),2,(LPVARIANT)p0,&_variant_t(GetResStr(IDS_PleasePickApointAsBOMInsertPointINAutoCAD)));
p0 = p1;
}
EDIBAcad::DrawTableACAD(p0, EDIBgbl::TZD, atan(1.0) * 0.0, rs, 0,1.0f, _T("YLB"));
}
// sTmp.Format(GetResStr(IDS_xDrawingFinished),EDIBgbl::Cbtype[EDIBgbl::TZD].MnuCaption);
// ShowMessage(sTmp);
break;
case iZDJDRAW180mm:
//每次计算一个支吊架时生成当前支吊架一览表,计算完成后总的一览表就生成了。
//每次计算一个支吊架时生成当前支吊架明细一览表,计算完成后总的明细一览表就生成了。
SQLx = _T("SELECT * FROM [") + EDIBgbl::Btype[EDIBgbl::TZD] + _T("] WHERE VolumeID=") + ltos(EDIBgbl::SelVlmID) + _T(" ORDER BY zdjh");
rs.m_pDatabase=&EDIBgbl::dbPRJDB;
rs.Open(dbOpenSnapshot,SQLx);
if(!rs.IsBOF() && !rs.IsEOF())
{//zsy 12/17 改为用ARX画图
ShowMessage(GetResStr(IDS_PleasePickApointAsZDJYLBInsertPointINAutoCAD));
if( EDIBAcad::gbACADR14 || !bIsCom ) //使用动态库画图
{
rs.Close();
}else
{
objTmp=EDIBAcad::objAcadDoc.GetPropertyByName(variant_t _T("Utility"));
p1=objTmp.Invoke(_T("GetPoint"),2,(LPVARIANT)p0,&_variant_t(GetResStr(IDS_PleasePickApointAsBOMInsertPointINAutoCAD)));
p0 = p1;
}
EDIBAcad::DrawTableACAD(p0, EDIBgbl::TZD180, atan(1.0) * 0.0, rs, 0 , 1.0f, _T("YLB"));
}
// sTmp.Format(GetResStr(IDS_xDrawingFinished),EDIBgbl::Cbtype[EDIBgbl::TZD180].MnuCaption);
// ShowMessage(sTmp);
break;
case iZDJDRAW270L:
SQLx = _T("SELECT * FROM [") + EDIBgbl::Btype[EDIBgbl::TZD] + _T("] WHERE ZDJH IN ( SELECT ZDJH FROM [")
+ EDIBgbl::Btype[EDIBgbl::TZA] + _T("] WHERE VolumeID=") + ltos(EDIBgbl::SelVlmID)
+ _T(" AND TYPE LIKE \'????\' ) AND VolumeID =")+ ltos(EDIBgbl::SelVlmID) + _T(" ORDER BY zdjh");
rs.m_pDatabase=&EDIBgbl::dbPRJDB;
rs.Open(dbOpenSnapshot,SQLx);
if(!rs.IsBOF() && !rs.IsEOF())
{//zsy 12/17 改为用ARX画图
ShowMessage(GetResStr(IDS_PleasePickApointAsZDJYLBInsertPointINAutoCAD));
if( EDIBAcad::gbACADR14 || !bIsCom ) //使用动态库画图
{
rs.Close();
}else
{
objTmp=EDIBAcad::objAcadDoc.GetPropertyByName(variant_t _T("Utility"));
p1=objTmp.Invoke(_T("GetPoint"),2,(LPVARIANT)p0,&_variant_t(GetResStr(IDS_PleasePickApointAsBOMInsertPointINAutoCAD)));
p0 = p1;
}
EDIBAcad::DrawTableACAD(p0, EDIBgbl::TZD270L, atan(1.0) * 0.0, rs, 0 , 1.0f, _T("YLB"));
}
// sTmp.Format(GetResStr(IDS_xDrawingFinished),EDIBgbl::Cbtype[EDIBgbl::TZD].MnuCaption);
// ShowMessage(sTmp);
break;
case iZDJDRAWEXECL:
SQLx = _T("SELECT * FROM [") + EDIBgbl::Btype[EDIBgbl::TZD] + _T("] WHERE ZDJH IN ( SELECT ZDJH FROM [")
+ EDIBgbl::Btype[EDIBgbl::TZA] + _T("] WHERE VolumeID=") + ltos(EDIBgbl::SelVlmID)
+ _T(" AND TYPE LIKE \'????\' ) AND VolumeID =")+ ltos(EDIBgbl::SelVlmID) + _T(" ORDER BY zdjh");
rs.m_pDatabase=&EDIBgbl::dbPRJDB;
rs.Open(dbOpenSnapshot,SQLx);
if(!rs.IsBOF() && !rs.IsEOF())
{
EDIBAcad::DrawTableExcel( EDIBgbl::TZDExcel, rs);
}
sTmp.Format(GetResStr(IDS_xDrawingFinished),EDIBgbl::Cbtype[EDIBgbl::TZDExcel].MnuCaption);
ShowMessage(sTmp);
break;
case iZDJDRAW705mm:
//判断是否所有支吊架计算完成。
SQLx = _T("SELECT * FROM [") + EDIBgbl::Btype[EDIBgbl::TZD] + _T("] WHERE VolumeID=") + ltos(EDIBgbl::SelVlmID) + _T(" ORDER BY zdjh");
rs.m_pDatabase=&EDIBgbl::dbPRJDB;
rs.Open(dbOpenSnapshot,SQLx);
if(!rs.IsBOF() && !rs.IsEOF())
{//zsy 12/17 改为用ARX画图
ShowMessage(GetResStr(IDS_PleasePickApointAsZDJYLBInsertPointINAutoCAD));
if( EDIBAcad::gbACADR14 || !bIsCom ) //使用动态库画图
{
rs.Close();
}else
{
objTmp=EDIBAcad::objAcadDoc.GetPropertyByName(variant_t _T("Utility"));
p1=objTmp.Invoke(_T("GetPoint"),2,(LPVARIANT)p0,&_variant_t(GetResStr(IDS_PleasePickApointAsBOMInsertPointINAutoCAD)));
p0 = p1;
}
EDIBAcad::DrawTableACAD(p0, EDIBgbl::TZD800, atan(1.0) * 0.0, rs, 0 , 1.0f, _T("YLB"));
}
// sTmp.Format(GetResStr(IDS_xDrawingFinished),EDIBgbl::Cbtype[EDIBgbl::TZD800].MnuCaption);
// ShowMessage(sTmp);
break;
case iZDJDRAW705mmHSY: ////核四院支吊架明细一览表
//判断是否所有支吊架计算完成。
SQLx = _T("SELECT * FROM [") + EDIBgbl::Btype[EDIBgbl::TZD] + _T("] WHERE VolumeID=") + ltos(EDIBgbl::SelVlmID) + _T(" ORDER BY zdjh");
rs.m_pDatabase=&EDIBgbl::dbPRJDB;
rs.Open(dbOpenSnapshot,SQLx);
if(!rs.IsBOF() && !rs.IsEOF())
{//zsy 12/17 改为用ARX画图
ShowMessage(GetResStr(IDS_PleasePickApointAsZDJYLBInsertPointINAutoCAD));
if( EDIBAcad::gbACADR14 || !bIsCom ) //使用动态库画图
{
rs.Close();
}else
{
objTmp=EDIBAcad::objAcadDoc.GetPropertyByName(variant_t _T("Utility"));
p1=objTmp.Invoke(_T("GetPoint"),2,(LPVARIANT)p0,&_variant_t(GetResStr(IDS_PleasePickApointAsBOMInsertPointINAutoCAD)));
p0 = p1;
}
EDIBAcad::DrawTableACAD(p0, EDIBgbl::TZD800HSY, atan(1.0) * 0.0, rs, 0 , 1.0f, _T("YLB"));
}
// sTmp.Format(GetResStr(IDS_xDrawingFinished),EDIBgbl::Cbtype[EDIBgbl::TZD800].MnuCaption);
// ShowMessage(sTmp);
break;
case iZDJDRAW705mmQGY: ////支吊架明细一览表
//判断是否所有支吊架计算完成。
SQLx = _T("SELECT * FROM [") + EDIBgbl::Btype[EDIBgbl::TZD] + _T("] WHERE VolumeID=") + ltos(EDIBgbl::SelVlmID) + _T(" ORDER BY zdjh");
rs.m_pDatabase=&EDIBgbl::dbPRJDB;
rs.Open(dbOpenSnapshot,SQLx);
if(!rs.IsBOF() && !rs.IsEOF())
{//zsy 12/17 改为用ARX画图
ShowMessage(GetResStr(IDS_PleasePickApointAsZDJYLBInsertPointINAutoCAD));
if( EDIBAcad::gbACADR14 || !bIsCom ) //使用动态库画图
{
rs.Close();
}else
{
objTmp=EDIBAcad::objAcadDoc.GetPropertyByName(variant_t _T("Utility"));
p1=objTmp.Invoke(_T("GetPoint"),2,(LPVARIANT)p0,&_variant_t(GetResStr(IDS_PleasePickApointAsBOMInsertPointINAutoCAD)));
p0 = p1;
}
EDIBAcad::DrawTableACAD(p0, EDIBgbl::TZD800QGY, atan(1.0) * 0.0, rs, 0 , 1.0f, _T("YLB"));
}
// sTmp.Format(GetResStr(IDS_xDrawingFinished),EDIBgbl::Cbtype[EDIBgbl::TZD800].MnuCaption);
// ShowMessage(sTmp);
break;
case iZDJDRAW270pc: //巴陵石化设计院支吊架表
//每次计算一个支吊架时生成当前当前支吊架一览表,计算完成后总的一览表就生成了。
//每次计算一个支吊架时生成当前当前支吊架明细一览表,计算完成后总的明细一览表就生成了。
SQLx = _T("SELECT * FROM [") + EDIBgbl::Btype[EDIBgbl::TZD] + _T("] WHERE VolumeID=") + ltos(EDIBgbl::SelVlmID) + _T(" ORDER BY zdjh");
rs.m_pDatabase=&EDIBgbl::dbPRJDB;
rs.Open(dbOpenSnapshot,SQLx);
if(!rs.IsBOF() && !rs.IsEOF())
{//zsy 12/17 改为用ARX画图
ShowMessage(GetResStr(IDS_PleasePickApointAsZDJYLBInsertPointINAutoCAD));
if( EDIBAcad::gbACADR14 || !bIsCom ) //使用动态库画图
{
rs.Close();
}else
{
objTmp=EDIBAcad::objAcadDoc.GetPropertyByName(variant_t _T("Utility"));
p1=objTmp.Invoke(_T("GetPoint"),2,(LPVARIANT)p0,&_variant_t(GetResStr(IDS_PleasePickApointAsBOMInsertPointINAutoCAD)));
p0 = p1;
}
EDIBAcad::DrawTableACAD(p0, EDIBgbl::TZP, atan(1.0) * 0.0, rs, 0 , 1.0f, _T("YLB"));
}
// sTmp.Format(GetResStr(IDS_xDrawingFinished),EDIBgbl::Cbtype[EDIBgbl::TZP].MnuCaption);
// ShowMessage(sTmp);
break;
case iZDJDRAWCatalogue:
// EDIBAcad::EraseAllEntities();
EDIBDB::DrawID = EDIBAcad::GetDrawIDAndName(1, EDIBDB::DrawName);
//绘制目录
//每次计算一个支吊架时生成当前当前支吊架图纸目录信息,计算完成后总的目录就生成了。
SQLx=_T("DELETE FROM [ML] WHERE VolumeID IS NULL AND ZDJH IS NULL");
EDIBgbl::dbPRJDB.Execute(SQLx);
SQLx = _T("SELECT * FROM [") + EDIBgbl::Btype[EDIBgbl::TML] + _T("] WHERE VolumeID=") + ltos(EDIBgbl::SelVlmID) + _T(" ORDER BY SEQ");
rs.m_pDatabase=&EDIBgbl::dbPRJDB;
rs.Open(dbOpenDynaset,SQLx);
if(!rs.IsBOF() && !rs.IsEOF())
{
//如果第一个图纸的序号>=1,在前面添加空的图纸目录,以便用户手工修改
if(!rs.FindFirst(_T("ZDJH <> NULL")))
return;
rs.GetFieldValue(_T("SEQ"),varTmp);
k = vtoi(varTmp);
for( i = 1 ;i< k ;i++)
{
if(!rs.FindFirst(_T("SEQ=") + ltos(i)))
{
rs.AddNew();
rs.SetFieldValue(_T("SEQ"),COleVariant((long)i));
rs.SetFieldValue(_T("Pages"),COleVariant((long)1));
rs.SetFieldValue(_T("DrawNo"),STR_VAR(_T("1")));
rs.SetFieldValue(_T("DrawNa"),STR_VAR(_T("1")));
rs.SetFieldValue(_T("Zdjh"),varNull);
rs.SetFieldValue(_T("VolumeID"),varNull);
rs.Update();
}
}
rs.Close();
//zsy 12/17 改为用ARX画图
SQLx = _T("SELECT * FROM [") + EDIBgbl::Btype[EDIBgbl::TML] + _T("] WHERE VolumeID IS NULL OR VolumeID=") + ltos(EDIBgbl::SelVlmID) + _T(" ORDER BY SEQ");
rs.Open(dbOpenDynaset,SQLx);
ShowMessage(GetResStr(IDS_PleasePickApointAsZDJYLBInsertPointINAutoCAD));
if( EDIBAcad::gbACADR14 || !bIsCom ) //使用动态库画图
{
rs.Close();
}else
{
objTmp=EDIBAcad::objAcadDoc.GetPropertyByName(variant_t _T("Utility"));
p1=objTmp.Invoke(_T("GetPoint"),2,(LPVARIANT)p0,&_variant_t(GetResStr(IDS_PleasePickApointAsBOMInsertPointINAutoCAD)));
p0 = p1;
}
EDIBAcad::DrawTableACAD(p0, EDIBgbl::TML, atan(1.0) * 0.0, rs, 0 , 1.0f, _T("ML"));
}
// sTmp.Format(GetResStr(IDS_xDrawingFinished),EDIBgbl::Cbtype[EDIBgbl::TML].MnuCaption);
// ShowMessage(sTmp);
break;
case iZDJDRAWCatalogueExcel:
EDIBDB::DrawID = EDIBAcad::GetDrawIDAndName(1, EDIBDB::DrawName);
//绘制目录
//每次计算一个支吊架时生成当前当前支吊架图纸目录信息,计算完成后总的目录就生成了。
SQLx=_T("DELETE FROM [ML] WHERE VolumeID IS NULL AND ZDJH IS NULL");
EDIBgbl::dbPRJDB.Execute(SQLx);
SQLx = _T("SELECT * FROM [") + EDIBgbl::Btype[EDIBgbl::TML] + _T("] WHERE VolumeID=") + ltos(EDIBgbl::SelVlmID) + _T(" ORDER BY SEQ");
rs.m_pDatabase=&EDIBgbl::dbPRJDB;
rs.Open(dbOpenDynaset,SQLx);
if(!rs.IsBOF() && !rs.IsEOF())
{
//如果第一个图纸的序号>=1,在前面添加空的图纸目录,以便用户手工修改
if(!rs.FindFirst(_T("ZDJH <> NULL")))
return;
rs.GetFieldValue(_T("SEQ"),varTmp);
k = vtoi(varTmp);
for( i = 1 ;i< k ;i++)
{
if(!rs.FindFirst(_T("SEQ=") + ltos(i)))
{
rs.AddNew();
rs.SetFieldValue(_T("SEQ"),COleVariant((long)i));
rs.SetFieldValue(_T("Pages"),COleVariant((long)1));
rs.SetFieldValue(_T("DrawNo"),STR_VAR(_T("1")));
rs.SetFieldValue(_T("DrawNa"),STR_VAR(_T("1")));
rs.SetFieldValue(_T("Zdjh"),varNull);
rs.SetFieldValue(_T("VolumeID"),varNull);
rs.Update();
}
}
rs.Close();
SQLx = _T("SELECT * FROM [") + EDIBgbl::Btype[EDIBgbl::TML] + _T("] WHERE VolumeID IS NULL OR VolumeID=") + ltos(EDIBgbl::SelVlmID) + _T(" ORDER BY SEQ");
rs.Open(dbOpenDynaset,SQLx);
EDIBAcad::DrawTableExcel(EDIBgbl::TMLE, rs);
}
sTmp.Format(GetResStr(IDS_xDrawingFinished),EDIBgbl::Cbtype[EDIBgbl::TML].MnuCaption);
ShowMessage(sTmp);
break;
case iZDJDRAWm_phs : //开始手工修改
EDIBAcad::MakeNewLayer(_T("M_phs0"), acRed);
break;
case iZDJDRAWXN180mm://绘制西南电力院的支吊架一览表
//Z8表
SQLx = _T("SELECT * FROM [") + EDIBgbl::Btype[EDIBgbl::TZD] + _T("] WHERE VolumeID=") + ltos(EDIBgbl::SelVlmID) + _T(" ORDER BY zdjh");
rs.m_pDatabase=&EDIBgbl::dbPRJDB;
rs.Open(dbOpenSnapshot,SQLx);
if(!rs.IsBOF() && !rs.IsEOF())
{//zsy 12/17 改为用ARX画图
ShowMessage(GetResStr(IDS_PleasePickApointAsZDJYLBInsertPointINAutoCAD));
if( EDIBAcad::gbACADR14 || !bIsCom ) //使用动态库画图
{
rs.Close();
}else
{
objTmp=EDIBAcad::objAcadDoc.GetPropertyByName(variant_t _T("Utility"));
p1=objTmp.Invoke(_T("GetPoint"),2,(LPVARIANT)p0,&_variant_t(GetResStr(IDS_PleasePickApointAsBOMInsertPointINAutoCAD)));
p0 = p1;
}
EDIBAcad::DrawTableACAD(p0, EDIBgbl::TZDSWED180, atan(1.0) * 0.0, rs, 0 , 1.0f, _T("YLB"));
}
// sTmp.Format(GetResStr(IDS_xDrawingFinished),EDIBgbl::Cbtype[EDIBgbl::TZDSWED180].MnuCaption);
// ShowMessage(sTmp);
break;
case iZDJDRAW705mmHBYZ: //华北冶建
//z9
SQLx = _T("SELECT * FROM [") + EDIBgbl::Btype[EDIBgbl::TZD] + _T("] WHERE VolumeID=") + ltos(EDIBgbl::SelVlmID) + _T(" ORDER BY zdjh");
rs.m_pDatabase=&EDIBgbl::dbPRJDB;
rs.Open(dbOpenSnapshot,SQLx);
if(!rs.IsBOF() && !rs.IsEOF())
{//zsy 12/17 改为用ARX画图
ShowMessage(GetResStr(IDS_PleasePickApointAsZDJYLBInsertPointINAutoCAD));
if( EDIBAcad::gbACADR14 || !bIsCom ) //使用动态库画图
{
rs.Close();
}else
{
objTmp=EDIBAcad::objAcadDoc.GetPropertyByName(variant_t _T("Utility"));
p1=objTmp.Invoke(_T("GetPoint"),2,(LPVARIANT)p0,&_variant_t(GetResStr(IDS_PleasePickApointAsBOMInsertPointINAutoCAD)));
p0 = p1;
}
EDIBAcad::DrawTableACAD(p0, EDIBgbl::TZD800HBYJ, atan(1.0) * 0.0, rs, 0 , 1.0f, _T("YLB"));
}
// sTmp.Format(GetResStr(IDS_xDrawingFinished),EDIBgbl::Cbtype[EDIBgbl::TZD800HBYJ].MnuCaption);
// ShowMessage(sTmp);
break;
case iZDJDRAWloadBJBW://北京巴威支吊荷载位移表
modPHScal::SetBasePoint();
modPHScal::PhsDisplacementLoadINFOMake("hz",0,EDIBgbl::TzDLOADNEW);
break;
//pfg20050601//北京华宇
case iZDJDRAWBJHY01:
//判断是否所有支吊架计算完成。
SQLx = _T("SELECT * FROM [") + EDIBgbl::Btype[EDIBgbl::TZD] + _T("] WHERE VolumeID=") + ltos(EDIBgbl::SelVlmID) + _T(" ORDER BY zdjh");
rs.m_pDatabase=&EDIBgbl::dbPRJDB;
rs.Open(dbOpenSnapshot,SQLx);
if(!rs.IsBOF() && !rs.IsEOF())
{//zsy 12/17 改为用ARX画图
ShowMessage(GetResStr(IDS_PleasePickApointAsZDJYLBInsertPointINAutoCAD));
if( EDIBAcad::gbACADR14 || !bIsCom ) //使用动态库画图
{
rs.Close();
}else
{
objTmp=EDIBAcad::objAcadDoc.GetPropertyByName(variant_t _T("Utility"));
p1=objTmp.Invoke(_T("GetPoint"),2,(LPVARIANT)p0,&_variant_t(GetResStr(IDS_PleasePickApointAsBOMInsertPointINAutoCAD)));
p0 = p1;
}
EDIBAcad::DrawTableACAD(p0, 36, atan(1.0) * 0.0, rs, 0 , 1.0f, _T("YLB"));
}
break;
case iZDJDRAWBJHY02:
//判断是否所有支吊架计算完成。
SQLx = _T("SELECT * FROM [") + EDIBgbl::Btype[EDIBgbl::TZD] + _T("] WHERE VolumeID=") + ltos(EDIBgbl::SelVlmID) + _T(" ORDER BY zdjh");
rs.m_pDatabase=&EDIBgbl::dbPRJDB;
rs.Open(dbOpenSnapshot,SQLx);
if(!rs.IsBOF() && !rs.IsEOF())
{//zsy 12/17 改为用ARX画图
ShowMessage(GetResStr(IDS_PleasePickApointAsZDJYLBInsertPointINAutoCAD));
if( EDIBAcad::gbACADR14 || !bIsCom ) //使用动态库画图
{
rs.Close();
}else
{
objTmp=EDIBAcad::objAcadDoc.GetPropertyByName(variant_t _T("Utility"));
p1=objTmp.Invoke(_T("GetPoint"),2,(LPVARIANT)p0,&_variant_t(GetResStr(IDS_PleasePickApointAsBOMInsertPointINAutoCAD)));
p0 = p1;
}
EDIBAcad::DrawTableACAD(p0, 37, atan(1.0) * 0.0, rs, 0 , 1.0f, _T("YLB"));
}
break;
//pfg20050601
}
}
catch(CDaoException *e)
{
e->ReportError();
e->Delete();
}
catch(_com_error e)
{
ShowMessage(e.Description());
}
catch(CException *e)
{
e->Delete();
}
catch(...)
{
}
}
void CMainFrame::OnDrawZdjTab270()
{
// TODO: Add your command handler code here
DrawZdjTab(iZDJDRAW270mm);
}
void CMainFrame::OnZdjDrawEP()
{
// TODO: Add your command handler code here
DrawZdjTab(iZDJDRAW705mm);
}
void CMainFrame::OnZdjDrawPC()
{
// TODO: Add your command handler code here
DrawZdjTab(iZDJDRAW270pc);
}
void CMainFrame::OnDrawZdjTML()
{
// TODO: Add your command handler code here
DrawZdjTab(iZDJDRAWCatalogue);
}
void CMainFrame::OnEraseAll()
{
// TODO: Add your command handler code here
EDIBAcad::EraseAllEntities();
}
void CMainFrame::OnEraseLayer()
{
EDIBAcad::DeleteAllEntitiesInLayers();
}
void CMainFrame::OnCadCel()
{
EDIBAcad::SetAcadNoTop();
//SetWindowPos(&wndTopMost,0,0,0,0,SWP_NOSIZE);
//SendMessage(SW_SHOW);
}
void CMainFrame::OnCadMenu()
{
EDIBAcad::DisplayAcadTop();
}
/*
void CMainFrame::OnDeleteLayerPhs()
{
EDIBAcad::DeleteAllEntitiesInLayers(1,_T("Phs"));
}*/
void CMainFrame::OnDeleteLayerTag()
{
EDIBAcad::DeleteAllEntitiesInLayers(1,_T("TAG"));
}
void CMainFrame::OnCouShowtab()
{
EDIBgbl::gbDisplayBOM = true;
//EDIBAcad::DisplayDataZB();
FrmDataEDIT.m_bAllowUpd=true;
if(!IsWindow(FrmDataEDIT.m_hWnd))
{
FrmDataEDIT.Create(IDD_DATAEDIT,AfxGetApp()->m_pMainWnd);
FrmDataEDIT.UpdateWindow();
}
//if(!FrmDataEDIT.IsWindowVisible())
::SetWindowPos(FrmDataEDIT.GetSafeHwnd(),HWND_TOP,0,0,0,0,/*SWP_NOACTIVATE|*/SWP_NOSIZE|SWP_NOMOVE|SWP_SHOWWINDOW);
}
/*
void CMainFrame::OnFileOutputBlock()
{
EDIBAcad::WblockFromPhsToPhsBlkDir(basDirectory::ProjectDir);
}*/
void CMainFrame::CalAllZdjh(LPVOID pParam)
{
/* try
{
int k,n,i=0;//第k个开始连续计算n个支吊架
CString sTmp;
AfxGetApp()->BeginWaitCursor();
if(FrmTxsr.m_pViewTxsr->m_bActive)
FrmTxsr.UpdateBoundData();
CRITICAL_SECTION crTmp;
::InitializeCriticalSection(&crTmp);
CInputBox dlg;
dlg.m_strTitle=_T("起始支吊架");
dlg.m_strWndText=_T("请输入从第k个支吊架开始");
dlg.m_strValue.Format(_T("%d"),(long)FrmTxsr.m_pViewTxsr->m_ActiveRs->GetCollect(_T("zdjh")));
dlg.DoModal();
while(dlg.m_strValue==_T("") || dlg.m_strValue.GetAt(0) < _T('0') || dlg.m_strValue.GetAt(0) > _T('9'))
dlg.DoModal();
k=_ttoi(dlg.m_strValue);
dlg.m_strTitle=_T("连续计算的支吊架个数");
dlg.m_strWndText=_T("请输入从第") + ltos(k) + _T("个支吊架开始,连续计算的支吊架个数n");
dlg.m_strValue.Format(_T("%d"),FrmTxsr.m_pViewTxsr->m_ActiveRs->RecordCount-(long)FrmTxsr.m_pViewTxsr->m_ActiveRs->GetCollect(_T("zdjh"))+1);
dlg.DoModal();
while(dlg.m_strValue==_T("") || dlg.m_strValue.GetAt(0) < _T('0') || dlg.m_strValue.GetAt(0) > _T('9'))
dlg.DoModal();
n=_ttoi(dlg.m_strValue);
//FrmTxsr.m_pViewTxsr->m_ActiveRs->Find (_T("zdjh=") + ltos(k));
modPHScal::gbCalAllPhs=true;
modPHScal::gbStopCalAllPHS = false;
frmStatus.ShowWindow(SW_SHOW);
frmStatus.m_btnStop.ShowWindow(SW_SHOW);
sTmp.Format(_T("%d"),modPHScal::zdjh);
frmStatus.m_Label1.Format(GetResStr(IDS_CalculatingNoXphs),sTmp); // _T("正在计算") & zdjh & _T("号支吊架")
frmStatus.m_Label2.Format(GetResStr(IDS_ApplyingSampleIDxPhs), ltos(modPHScal::iSelSampleID)); //_T("正在使用") & iSelSampleID & _T("号样本支吊架组合结构")
frmStatus.SetWindowText(GetResStr(IDS_AllPhsCalculation)); // _T("计算全部支吊架")
frmStatus.UpdateData(false);
frmStatus.UpdateStatus(0.0,true);
CMainFrame* frm=(CMainFrame*)pParam;
frmStatus.SetWindowText(GetResStr(IDS_AllPhsCalculation)); // _T("计算全部支吊架")
while (!FrmTxsr.m_pViewTxsr->m_ActiveRs->adoEOF && !modPHScal::gbStopCalAllPHS && ( i < n))
{//frmStatus.Show
i++;
sTmp.Format (_T("%d"),modPHScal::zdjh);
CString s1,s2;
s1.Format (GetResStr(IDS_CalculatingNoXphs),sTmp); // _T("正在计算") & zdjh & _T("号支吊架")
s2.Format (GetResStr(IDS_ApplyingSampleIDxPhs), ltos(modPHScal::iSelSampleID)); //_T("正在使用") & iSelSampleID & _T("号样本支吊架组合结构")
frmStatus.m_ctrLabel1.SetWindowText(s1);
frmStatus.m_ctrLabel2.SetWindowText(s2);
frmStatus.UpdateStatus(i / n,true);
if(modPHScal::gbStopCalAllPHS) break;
modPHScal::VB_Cal(FrmTxsr.m_pViewTxsr->m_ActiveRs ,modPHScal::zdjh);
::EnterCriticalSection(&crTmp);
FrmTxsr.m_pViewTxsr->m_ActiveRs->MoveNext();
::LeaveCriticalSection(&crTmp);
//SetWindowTop Me.hwnd
}
modPHScal::gbCalAllPhs = false;
ShowMessage(GetResStr(IDS_AllPhsCalculationFinished)); //_T("所有支吊架计算完毕!")
AfxGetApp()->EndWaitCursor();
frmStatus.ShowWindow(SW_HIDE);
frmStatus.m_btnStop.ShowWindow(SW_HIDE);
::DeleteCriticalSection(&crTmp);
}
catch(...)
{
}*/
}
void CMainFrame::OnDrawChangeDim()
{
// TODO: Add your command handler code here
if(FAILED(EDIBAcad::objAcadApp.GetActiveObject(EDIBAcad::gstrApplicatonName)))
return;
EDIBAcad::DrawphsDataEdit();
}
void CMainFrame::LoadRecentFiles()
{
int i,c;
CString stmp,sfile;
CMenu* menu=GetMenu()->GetSubMenu(0);
CMenu* menu1;
if(menu==NULL)
return;
c=menu->GetMenuItemCount();
for(i=0;i<c;i++)
{
menu1=menu->GetSubMenu(i);
if(menu1)
{
menu=menu1;
break;
}
}
if(menu1==NULL)
return;
c=menu->GetMenuItemCount();
for(i=c;i>0;i--)
{
menu->DeleteMenu(i-1,MF_BYPOSITION);
}
m_nRecFileNum=0;
for(i=0; i<8;i++)
{
stmp.Format(_T("%d"),i+1);
if((sfile =::GetRegKey(_T("RecentFiles"),stmp,CString(_T("")))) != _T(""))
{
sfile=CString(_T("&"))+stmp+_T(" ") +sfile;
menu->InsertMenu(i, MF_BYPOSITION | MF_STRING , ID_REC_FILE1+i , sfile);
m_nRecFileNum++;
}
}
if(m_nRecFileNum==0)
menu->InsertMenu(0,MF_BYPOSITION|MF_STRING|MF_DISABLED|MF_GRAYED,ID_REC_FILE1-1,GetResStr(IDS_NO_LATELY_USE_FILE));
}
void CMainFrame::AddRecentFiles(CString FileName)
{
CString stmp,sfile;
int i,k;
FileName.MakeLower();
for(k=1;k<=8;k++)
{
stmp.Format(_T("%d"),k);
sfile=GetRegKey(_T("RecentFiles"),stmp,CString(_T("")));
sfile.MakeLower();
if(sfile==FileName)
break;
}
if(k>8) k=8;
for(i=k;i>1;i--)
{
stmp.Format(_T("%d"),i-1);
sfile=GetRegKey(_T("RecentFiles"),stmp,CString(_T("")));
stmp.Format(_T("%d"),i);
::SetRegValue(_T("RecentFiles"),stmp,sfile);
}
::SetRegValue(_T("RecentFiles"),_T("1"),FileName);
}
void CMainFrame::OnRecFile1()
{
// TODO: Add your command handler code here
mnuRecFile_Click(ID_REC_FILE1);
}
void CMainFrame::OnRecFile2()
{
// TODO: Add your command handler code here
mnuRecFile_Click(ID_REC_FILE2);
}
void CMainFrame::OnRecFile3()
{
// TODO: Add your command handler code here
mnuRecFile_Click(ID_REC_FILE3);
}
void CMainFrame::OnRecFile4()
{
// TODO: Add your command handler code here
mnuRecFile_Click(ID_REC_FILE4);
}
void CMainFrame::OnRecFile5()
{
// TODO: Add your command handler code here
mnuRecFile_Click(ID_REC_FILE5);
}
void CMainFrame::OnRecFile6()
{
// TODO: Add your command handler code here
mnuRecFile_Click(ID_REC_FILE6);
}
void CMainFrame::OnRecFile7()
{
// TODO: Add your command handler code here
mnuRecFile_Click(ID_REC_FILE7);
}
void CMainFrame::OnRecFile8()
{
// TODO: Add your command handler code here
mnuRecFile_Click(ID_REC_FILE8);
}
void CMainFrame::mnuRecFile_Click(int nID)
{
if(!ModEncrypt::gbLegalUser)
{
ShowMessage(GetResStr(IDS_IllegalUserOrDemoVerCantStartACAD));
return;
}
int i,c;
CMenu* menu=GetMenu()->GetSubMenu(0);
CMenu* menu1;
if(menu==NULL)
return;
c=menu->GetMenuItemCount();
for(i=0;i<c;i++)
{
menu1=menu->GetSubMenu(i);
if(menu1)
{
menu=menu1;
break;
}
}
if(menu1==NULL)
return;
CString sfile;
menu->GetMenuString(nID,sfile,MF_BYCOMMAND);
modPHScal::gsDwgFN =sfile.Mid(3);
if(modPHScal::gsDwgFN != _T(""))
{
EDIBAcad::StartAcad(modPHScal::gsDwgFN);
AddRecentFiles(modPHScal::gsDwgFN);
LoadRecentFiles();
}
}
//DEL void CMainFrame::OnActivateApp(BOOL bActive, HTASK hTask)
//DEL {
//DEL CFrameWnd::OnActivateApp(bActive, hTask);
//DEL
//DEL // TODO: Add your message handler code here
//DEL if(bActive==FALSE)
//DEL {
//DEL if(IsWindow(m_hWnd))
//DEL ::SetWindowPos(m_hWnd,HWND_TOP,0,0,0,0,SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOSIZE);
//DEL }
//DEL }
void CMainFrame::OnUpdateSpecPa(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetText(modPHScal::gsPhsPASel);
pCmdUI->Enable();
}
void CMainFrame::OnUpdateSpecCspr(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetText(modPHScal::gsPhsConstantSpringSel);
pCmdUI->Enable();
}
void CMainFrame::OnUpdateSpecBolts(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetText(modPHScal::gsPhsBoltsNutsSel);
pCmdUI->Enable();
}
void CMainFrame::OnUpdateSpecPart(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetText(modPHScal::gsPhsPARTSel);
pCmdUI->Enable();
}
void CMainFrame::OnUpdateSpecSa(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetText(modPHScal::gsPhsSASel);
pCmdUI->Enable();
}
void CMainFrame::OnUpdateSpecSpr(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetText(modPHScal::gsPhsSPRINGSel);
pCmdUI->Enable();
}
BOOL CMainFrame::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
return CFrameWnd::PreTranslateMessage(pMsg);
}
void CMainFrame::OnCalAddmaterial()
{
// TODO: Add your command handler code here
CDlgAddMaterial dlg;
dlg.DoModal();
}
void CMainFrame::OnCalAllowMaxSpan()
{
// TODO: Add your command handler code here
if(!IsWindow(gDlgSpan.GetSafeHwnd()))
gDlgSpan.Create(IDD_DIALOG_SPAN,this);
gDlgSpan.ShowWindow(SW_SHOW);
gDlgSpan.UpdateWindow();
}
void CMainFrame::OnDrawZdjtabl()
{
// TODO: Add your command handler code here
DrawZdjTab(iZDJDRAW270L);
}
void CMainFrame::OnDrawZdjtablExce()
{
// TODO: Add your command handler code here
DrawZdjTab(iZDJDRAWEXECL);
}
void CMainFrame::OnSumExcel()
{
// TODO: Add your command handler code here
SumCL(4);
}
void CMainFrame::OnDrawZdjdirExecl()
{
// TODO: Add your command handler code here
DrawZdjTab(iZDJDRAWCatalogueExcel);
}
void CMainFrame::OnFileOpenDb()
{
// TODO: Add your command handler code here
CFileDialogEx fileDlg(TRUE,NULL,NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,_T("Database Files(*.mdb)|*.mdb|All Files(*.*)|*.*||"));
if(fileDlg.DoModal()==IDOK)
{
CDlgEditDB dlg;
dlg.m_strDBName=fileDlg.GetPathName();
dlg.DoModal();
}
}
void CMainFrame::OnToolWblock()
{
// TODO: Add your command handler code here
try
{
EDIBAcad::objAcadDoc.Invoke( _T("SendCommand"),1,&_variant_t(_T("phsw\n")));
}
catch(...)
{
}
}
void CMainFrame::OnToolInsertUserBlock()
{
// TODO: Add your command handler code here
try
{
EDIBAcad::objAcadDoc.Invoke(_T("SendCommand"),1,&_variant_t(_T("phsr\n")));
}
catch(...)
{
}
}
void CMainFrame::OnUpdateToolWblock(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
if(EDIBAcad::gbACADR14)
pCmdUI->Enable(FALSE);
else
pCmdUI->Enable();
}
void CMainFrame::OnUpdateToolInsertuserblock(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
if(EDIBAcad::gbACADR14)
pCmdUI->Enable(FALSE);
else
pCmdUI->Enable();
}
LRESULT CMainFrame::OnUpdOption(WPARAM wParam, LPARAM lParam)
{
modPHScal::ReadAutoPHSiniValue();
return TRUE;
}
void CMainFrame::OnPdmstophs()
{
// TODO: Add your command handler code here
ReadPDMS();
}
void CMainFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
{
// TODO: Add your message handler code here and/or call default
CRect rc1;
::SystemParametersInfo(SPI_GETWORKAREA,0,(LPVOID)&rc1,0);
lpMMI->ptMaxPosition.x=0;
lpMMI->ptMaxPosition.y=0;
lpMMI->ptMaxSize.x=rc1.right;
lpMMI->ptMaxSize.y=this->GetMenuHeight();
}
void CMainFrame::OnMoving(UINT fwSide, LPRECT pRect)
{
//CFrameWnd::OnMoving(fwSide, pRect);
// TODO: Add your message handler code here
CRect rc1;
::SystemParametersInfo(SPI_GETWORKAREA,0,(LPVOID)&rc1,0);
//pRect->left=pRect->top=0;
//pRect->right=rc1.right;
pRect->top=0;
pRect->bottom=this->GetMenuHeight();
}
void CMainFrame::OnPhstToPdms()
{
// TODO: Add your command handler code here
CFileDialogEx filedlg(FALSE,NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
GetResStr(IDS_PDMSFILES_FILTER),this);
if(filedlg.DoModal()==IDOK)
{
::PHSToPDMS(filedlg.GetPathName());
}
}
void CMainFrame::OnUpdatePdmsToPhs(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->Enable(TRUE);
}
void CMainFrame::OnUpdatePhsToPdms(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->Enable(TRUE);
}
void CMainFrame::OnCalStruct()
{
// TODO: Add your command handler code here
CCalStructDlg dlg;
dlg.DoModal();
}
void CMainFrame::OnClose()
{
// TODO: Add your message handler code here and/or call default
CString sTmp;
sTmp.Format(GetResStr(IDS_ReallyExitThisForm),EDIBgbl::gsTitle);
if(ShowMessage(sTmp,MB_YESNO|MB_ICONQUESTION) != IDYES)
return;
CFrameWnd::OnClose();
}
BOOL CMainFrame::Start()
{
EDIBgbl::gsTitle = _T("优易管道支吊架设计");
EDIBgbl::gsTitle+=_T("(") + ModEncrypt::gstrLegalCompanyName + _T(")");
SetWindowText(EDIBgbl::gsTitle);
CString strTemp;
strTemp.Format(_T("%d"),this->GetSafeHwnd());
SetRegValue(_T("Settings"),_T("MainWndHandle"),strTemp);
gObjMainFrm=_T("AutoPHSD");
CFileStatus filstat;
CRect rc,rc1;
::SystemParametersInfo(SPI_GETWORKAREA,0,(LPVOID)&rc1,0);
int screenW=GetSystemMetrics(SM_CXSCREEN);
this->SetWindowPos(NULL,0,0,rc1.Width(),GetMenuHeight(),SWP_NOACTIVATE|SWP_NOZORDER);
ShowWindow(SW_SHOW);
Cavphs=new Cphs;
modPHScal::ReadAutoPHSiniValue();
if(! ModEncrypt::gbLegalUser)
{
CMenu* menu=this->GetMenu();
menu->EnableMenuItem(5,MF_DISABLED|MF_GRAYED|MF_BYPOSITION);
menu->EnableMenuItem(6,MF_DISABLED|MF_GRAYED|MF_BYPOSITION);
}
if( FileExists( basDirectory::InstallDir + _T("AutoPHS.chm")) )
{
AfxGetApp()->m_pszHelpFilePath = _tcsdup(basDirectory::InstallDir+_T("AutoPHS.chm"));
}
else if ( FileExists( basDirectory::InstallDir + _T("PHS\\Help\\AutoPHS.chm") ) )
{
AfxGetApp()->m_pszHelpFilePath = _tcsdup( basDirectory::InstallDir + _T("PHS\\Help\\AutoPHS.chm") );
}
else
{
AfxGetApp()->m_pszHelpFilePath = _tcsdup( user::GetAppPath() + _T("\\AutoPHS.chm") );
}
if(!IsWindow(frmStatus.m_hWnd))
frmStatus.Create(IDD_STATUS,this);
if(FrmSplash!=NULL && IsWindow(FrmSplash->m_hWnd))
{
FrmSplash->GetWindowRect(&rc);
frmStatus.GetWindowRect(&rc1);
int H=rc1.Height();
int W=rc1.Width();
int SW=::GetSystemMetrics(SM_CXSCREEN);
rc1.left=(SW-W)/2;
rc1.right=rc1.left+W;
rc1.top=rc.bottom+1;
rc1.bottom=rc1.top+H;
frmStatus.MoveWindow(&rc1);
}
Timer1Interval=10; //仅在计算时打开
::AfxGetApp()->LoadCursor(IDC_WAIT);
SetMenuEnabled();
//以下两句打开了所有的数据库连接
modPHScal::dbZDJcrude.Open(basDirectory::ProjectDBDir+_T("zdjcrude.mdb"),FALSE,FALSE,_T(";pwd=")+ModEncrypt::gstrDBZdjCrudePassWord);
EDIBgbl::InitCurrWork();
modPHScal::InitZdjTxName();
if(!modPHScal::blnSelAndSaveSPEC() )
{
if(ShowModalSelSpecification()==ID_SELEXIT)
{
m_bIsExitMsg=false;
return FALSE;
}
}
if(IsWindow(frmStatus.m_hWnd) && ::frmStatus.IsWindowVisible()) frmStatus.ShowWindow(SW_HIDE);
//20071025 "ProjectDBDir" 改为 "DBShareDir"
conPRJDB.CreateInstance(__uuidof(Connection));
conPRJDB->Open(_bstr_t(::dbConnectionString+basDirectory::DBShareDir+_T("AllPrjDB.mdb")),_T(""),_T(""),0);
try
{
conZDJCrude.CreateInstance(__uuidof(Connection));
conZDJCrude->Open(_bstr_t(::dbConnectionString+basDirectory::ProjectDBDir+_T("ZDJcrude.mdb")),_T(""),_T(""),0);
}
catch (_com_error* e)
{
//ShowMessage(e->Description());
}
LoadRecentFiles();
if(!IsWindow(FrmTxsr.m_hWnd))
{
FrmTxsr.Create(this);
}
FrmTxsr.ShowWindow(SW_HIDE);
OnIntTabint();
CString ss=EDIBgbl::gsTitle+(EDIBgbl::TBNSelPrjSpec == _T("") ? _T("") : (_T(" ") + EDIBgbl::TBNSelPrjSpec + EDIBgbl::Btype[EDIBgbl::SelBillType] + _T(" (") + EDIBgbl::SelJcdm + _T(")")));
SetWindowText(ss);
return TRUE;
}
void CMainFrame::OnUpdateIntImpdata(CCmdUI* pCmdUI)
{
pCmdUI->Enable(FALSE);
}
void CMainFrame::OnModifyZdjh()
{
// TODO: Add your command handler code here
CDlgModifyZdjh dlg(EDIBgbl::SelVlmID,this);
if(dlg.DoModal()==IDOK)
{
}
}
//cheng
void CMainFrame::OnGuideEnter()
{
modPHScal::SelInputMethod = 2;
Guide GuideEnter;
GuideEnter.DoModal();
}
void CMainFrame::OnZdjXn()
{
//西南院支吊架明细一览表(180mm,A4)
DrawZdjTab(iZDJDRAWXN180mm );
}
void CMainFrame::OnExportCurrentVolume()
{
CDlgExportVolume exportDlg;
if( exportDlg.DoModal()==IDOK )
{
}
}
void CMainFrame::OnImportVolume()
{
CString strSQL;
_RecordsetPtr rsRefresh(__uuidof(Recordset));
::FrmPhsData.m_DBGbill.SetRefDataSource(NULL);
FrmTxsr.m_pViewTxsr->m_Databill.SetRefRecordset(NULL);
//import...
//_bstr_t(dbConnectionString + m_strPrjDBDir + "AllPrjDB.mdb"),
// rsRefresh->Open(strSQL,pCon,adOpenStatic,adLockOptimistic,adCmdText);
FrmTxsr.m_pViewTxsr->m_bAllowUpd=false;
FrmTxsr.m_pViewTxsr->m_Databill.SetRefRecordset(rsRefresh);
FrmTxsr.m_pViewTxsr->m_Databill.SetEnabled(TRUE);
FrmPhsData.m_DBGbill.SetRefDataSource(rsRefresh);
EDIBDB::SetColumnsProperty(FrmPhsData.m_DBGbill, EDIBgbl::SelBillType);
FrmTxsr.m_pViewTxsr->m_bAllowUpd=true;
}
void CMainFrame::OnFileBackupDB()
{
CTime time;
CString strFmtTime;
CString strVersion;
CString strAppInstallPath;
DWORD dwVersion=user::GetVersion();
strVersion.Format(_T("v%d.%d"),MAJOR(dwVersion),MINOR(dwVersion));
time = time.GetCurrentTime();
strFmtTime.Format("%d.%d.%d_%d.%d.%d_%s",time.GetYear(),time.GetMonth(),time.GetDay(),
time.GetHour(),time.GetMinute(),time.GetSecond(),strVersion);
strAppInstallPath = GetRegKey(_T("Directory"), _T("EDInBox_InsDir"), CString(_T("")));
//Create Directory for backup
//////////////////////////////////////////////////////////////////
CString strBackupPath;
strBackupPath = strAppInstallPath+"BackupDB"; CreateDirectory(strBackupPath,NULL);
strBackupPath = strBackupPath + "\\" + strFmtTime;
if( !CreateDirectory(strBackupPath,NULL) )
{
AfxMessageBox("备份失败,可能是硬盘空间不足");
return;
}
//////////////////////////////////////////////////////////////////
//Backup File...
//////////////////////////////////////////////////////////////////
CString strPrjDBDir = GetRegKey(_T("Directory"),_T("EDInBox_PrjDBDir"),CString(""));
CopyFile(strPrjDBDir+"AllPrjDB.mdb",strBackupPath+"\\AllPrjDB.mdb",FALSE);
CopyFile(strPrjDBDir+"Sort.mdb",strBackupPath+"\\Sort.mdb",FALSE);
//////////////////////////////////////////////////////////////////
}
void CMainFrame::OnFileRestoreDB()
{
CDlgBackupUndo dlg;
dlg.DoModal();
}
//Modified by Shuli Luo
//Modify Date : 2003-12-26
void CMainFrame::OnAutoUpdate()
{
// TODO: Add your command handler code here
CString strRegPath = "SOFTWARE\\长沙优易软件开发有限公司\\AutoUpdate";
CString strListFile;
HKEY hKey;
BYTE szUpdateExeFile[MAX_PATH];
CString strUpdateExeFile;
DWORD dwType,dwLen;
dwType = REG_SZ;
dwLen = MAX_PATH;
memset(szUpdateExeFile,0,MAX_PATH);
REG_CALL(RegOpenKeyEx(HKEY_LOCAL_MACHINE,strRegPath,0,KEY_ALL_ACCESS,&hKey),"读取注册表失败,请检查您的自动更新组件是否安装");
REG_CALL(RegQueryValueEx(hKey,"Shell",NULL,&dwType,szUpdateExeFile,&dwLen),"读取注册表失败,请检查您的自动更新组件是否安装");
REG_CALL(RegCloseKey(hKey),"读取注册表失败,请检查您的自动更新组件是否安装");
GetModuleFileName(NULL,strListFile.GetBuffer(MAX_PATH),MAX_PATH);
strListFile.ReleaseBuffer();
strListFile = strListFile.Left(strListFile.ReverseFind('\\')) + "\\AutoPHS.AUO";
strUpdateExeFile = szUpdateExeFile;
//AfxMessageBox("Let's Go");
ShellExecute(NULL,"open",(LPCSTR)szUpdateExeFile,
strListFile,strUpdateExeFile.Left(strUpdateExeFile.ReverseFind('\\')),SW_SHOW);
}
//Modify Ended
void CMainFrame::OnDrawZdjArx()
{
// TODO: Add your command handler code here
try
{
CString sTmp,sTmp2;
modPHScal::zdjh=(long)FrmTxsr.m_pViewTxsr->m_ActiveRs->GetCollect(_T("zdjh"));
if(vtob(FrmTxsr.m_pViewTxsr->m_ActiveRs->GetCollect(_T("bCalSuccess")))==false)
{
CString strMsg;
strMsg.Format(IDS_NO_DRAWPHS,modPHScal::zdjh);
ShowMessage(strMsg);
return;
}
modPHScal::iSelSampleID=(long)FrmTxsr.m_pViewTxsr->m_ActiveRs->GetCollect(_T("iSelSampleID"));
//pfg20050328
_variant_t key;
_RecordsetPtr mlSet;
CString strZdjh;
CString strVolumeID;
CString strSQL;
CString strPhsName;
strZdjh.Format("%ld",modPHScal::zdjh);
strVolumeID.Format("%ld",EDIBgbl::SelVlmID);
try
{
mlSet.CreateInstance(__uuidof(Recordset));
strSQL="select * from ml where Volumeid="+strVolumeID+" and zdjh="+strZdjh+"";
mlSet->Open(_variant_t(strSQL),(IDispatch*)conPRJDB,/*adOpenDynamic*/adOpenStatic,adLockOptimistic,adCmdText);
key=mlSet->GetCollect(_T("DRAWNA"));
if(!(key.vt==VT_NULL||key.vt==VT_EMPTY))
{
strPhsName=key.bstrVal;
SetRegValue(_T("Settings"),_T("PhsCurZDJName"), strPhsName);
}
}catch(_com_error e)
{
// AfxMessageBox(e.Description());
}
if(mlSet->State==adStateOpen)
{
mlSet->Close();
}
//pfg20050328
SetRegValue(_T("Settings"),_T("PhsCurZdjhNo"),modPHScal::zdjh);
SetRegValue(_T("Settings"),_T("DrawFlag"),bool(true));
gStartAcad();
EDIBAcad::DisplayAcadTop();
EDIBAcad::objAcadDoc=EDIBAcad::objAcadApp.GetPropertyByName(variant_t _T("ActiveDocument"));
EDIBAcad::objAcadDoc.Invoke(_T("SendCommand"),1,&_variant_t(_T("drawzdj\n")));
SetRegValue(_T("Settings"),_T("DrawFlag"),bool(false));
EDIBAcad::MakeNewLayer(_T("DIM"));
modPHScal::gsPhsColor.MakeUpper();
if(modPHScal::gsPhsColor==_T("WHITE"))
{
EDIBAcad::MakeNewLayer(_T("Phs"), acWhite);
}
else
{
if(modPHScal::gsPhsColor== _T("GREEN") )
{
EDIBAcad::MakeNewLayer(_T("phs"), acGreen);
}
else
{
EDIBAcad::MakeNewLayer(_T("phs"));
}
}
EDIBAcad::SetDimVariables();
return;
}
catch(::CDaoException* e)
{
e->ReportError();
e->Delete();
}
catch(COleException* e)
{
e->ReportError();
e->Delete();
}
catch(_com_error e)
{
MessageBox(e.Description());
}
catch(CException *e)
{
e->Delete();
}
catch(...)
{
}
}
BOOL gStartAcad()
{
CString tmpsz;
_variant_t VarName;
_variant_t tmpvar;
CString strTmp,strTmp2;
static int StartCount=0;
AfxGetApp()->BeginWaitCursor();
try
{
//11/10 PFG
if(::FileExists(basDirectory::InstallDir+_T("phs2000.mnc")))
{
CFile::Remove(basDirectory::InstallDir+_T("phs2000.mnc"));
}
//11/10 PFG
if(FAILED(EDIBAcad::objAcadApp.GetActiveObject(EDIBAcad::gstrApplicatonName)))
{
StartCount=0;
if(FAILED(EDIBAcad::objAcadApp.CreateObject(EDIBAcad::gstrApplicatonName)))
{
ShowMessage( GetResStr(IDS_NotStartAcad));
return FALSE;
}
}
tmpvar=EDIBAcad::objAcadApp.GetPropertyByName(variant_t _T("Path"));
basDirectory::AcadwinDir=vtos(tmpvar);
user::AddDirSep(basDirectory::AcadwinDir);
user::AddDirSep(basDirectory::TemplateDir);
if(!::FileExists(basDirectory::AcadwinDir+_T("fonts\\hzfs.shx")))
{
if(!CopyFile(basDirectory::TemplateDir + _T("hzfs.shx"),basDirectory::AcadwinDir + _T("fonts\\hzfs.shx"),FALSE))
{
if(FileExists(basDirectory::AcadwinDir +_T("fonts\\hztxt.shx")))
CopyFile(basDirectory::AcadwinDir +_T("fonts\\hztxt.shx"),basDirectory::AcadwinDir+_T("fonts\\hzfs.shx"),FALSE);
else
ShowMessage(GetResStr(IDS_AT) + basDirectory::AcadwinDir +GetResStr(IDS_CANNOTSHOW));
}
}
if(!::FileExists(basDirectory::AcadwinDir+_T("fonts\\hztxt.shx")))
{
if(CopyFile(basDirectory::TemplateDir + _T("hzfs.shx"),basDirectory::AcadwinDir + _T("fonts\\hztxt.shx"),FALSE))
{
}
}
tmpvar=EDIBAcad::objAcadApp.GetPropertyByName(variant_t _T("Version"));
EDIBAcad::gsACADVER=vtos(tmpvar);
if(EDIBAcad::gsACADVER.Left(2)==_T("14"))
{
EDIBAcad::gbACADR14=true;
CMObject ObjPreferences;
ObjPreferences=EDIBAcad::objAcadApp.GetPropertyByName(variant_t _T("Preferences"));
_variant_t varStr;
varStr.SetString("<<Unnamed Profile>>");
ObjPreferences.PutPropertyByName(_T("ActiveProfile"),&varStr);
EDIBAcad::gbACADR2000 = false;
}
else
{
EDIBAcad::gbACADR14 = false;
if(EDIBAcad::gsACADVER.Left(2)==_T("15"))
{
EDIBAcad::gbACADR2000 = true;
}
else
{
EDIBAcad::gbACADR2000 = false;
}
}
EDIBAcad::MoSpace=EDIBAcad::objAcadDoc.GetPropertyByName(variant_t _T("ModelSpace"));
EDIBAcad::PaSpace=EDIBAcad::objAcadDoc.GetPropertyByName(variant_t _T("PaperSpace"));
//Set OSNAP mode for duration of the VB program
EDIBAcad::sysVarName = _T("OSMODE");
VarName=_variant_t(EDIBAcad::sysVarName);
tmpvar=EDIBAcad::objAcadDoc.Invoke(_T("GetVariable"),1,&VarName);
//sysVarData =(char*)_bstr_t(tmpvar);
EDIBAcad::osMode = tmpvar.operator long();//VT_I2
tmpvar.ChangeType(VT_I2);
tmpvar.intVal=0;
EDIBAcad::objAcadDoc.Invoke(_T("SetVariable"),2,&VarName,&tmpvar);
//设置尺寸变量
EDIBAcad::SetACADCurrentStyle(_T("Dim"),modPHScal::strBigFontDim,modPHScal::strSHXFontDim,modPHScal::fFWDim);
EDIBAcad::SetACADCurrentStyle(_T("BOM"),modPHScal::strBigFontLjmx,modPHScal::strSHXFontLjmx,modPHScal::fFWLjmx);
EDIBAcad::SetACADCurrentStyle(_T("LOAD"),modPHScal::strBigFontLoad,modPHScal::strSHXFontLoad,modPHScal::fFWLoad);
EDIBAcad::SetACADCurrentStyle(_T("hz"));
EDIBAcad::objAcadDoc.Invoke(_T("SetVariable"),2,&_variant_t(_T("DIMTXSTY")),&_variant_t(_T("Dim")));
tmpvar.ChangeType(VT_R8);
tmpvar.dblVal=EDIBAcad::g_fDistanceOffset;
VarName=_variant_t(_T("dimexo"));
EDIBAcad::objAcadDoc.Invoke(_T("SetVariable"),2,&VarName,&tmpvar);
//超过尺寸线的部分
tmpvar.dblVal=EDIBAcad::g_fOvertopDim;
VarName=_variant_t(_T("dimexe"));
EDIBAcad::objAcadApp.Invoke(_T("SetVariable"),2,&VarName,&tmpvar);
tmpvar.ChangeType(VT_BOOL);
tmpvar.boolVal=TRUE;
EDIBAcad::objAcadApp.PutPropertyByName(_T("Visible"),&tmpvar);
//if(StartCount==0)
// ShowMessage( GetResStr(IDS_AcadStartFinished),MB_SYSTEMMODAL|MB_OK);// vbAfxMessageBox(SetForeground + vbSystemModal*/
StartCount++;
EDIBAcad::LoadMyArx("PHS.arx");
// EDIBAcad::LoadMyArx("sm.arx");
}
catch(CException *e)
{
e->Delete();
}
catch(...)
{
CString str;
str.LoadString(IDS_AUTOCAD_INITIALIZE_ERROR);
ShowMessage(str);
return FALSE;
}
return TRUE;
}
void CMainFrame::OnUpdateDrawZdj(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
_variant_t tmpvar;
CString str("");
try
{
if(SUCCEEDED(EDIBAcad::objAcadApp.GetActiveObject(EDIBAcad::gstrApplicatonName)))
{
tmpvar=EDIBAcad::objAcadApp.GetPropertyByName(variant_t _T("Version"));
str = vtos(tmpvar);
if(str.Left(2)==_T("14"))
{
pCmdUI->Enable(false);
}
else
{
pCmdUI->Enable(true);
}
return;
}
if(modPHScal::gIsACAD==0)//使用AutoCAD
{
CString data_Set;
data_Set = "SOFTWARE\\Autodesk\\AutoCAD\\";
HKEY hKEY;
long ret0 = RegOpenKeyEx(HKEY_LOCAL_MACHINE,data_Set,0,KEY_READ,&hKEY);
if(ret0 != ERROR_SUCCESS)
{
return ;
}
LPBYTE owner_Get=new BYTE[MAX_PATH];
DWORD type_1=REG_SZ; //定义数据类型
DWORD cbData_1=MAX_PATH; //定义数据长度
long ret1=::RegQueryValueEx(hKEY,"CurVer",NULL,&type_1,owner_Get,&cbData_1);
if(ret1!=ERROR_SUCCESS)
{
//查找当前版本信息时.在2004版或以上.CAD不建立"CurVer"项的值. ZSY
//如果查找失败,可能是2004版或以上的.或者计算机没安装CAD.
// AfxMessageBox("错误:无法查询有关的注册表信息");
// return ;
}
str = owner_Get;
delete []owner_Get;
::RegCloseKey(hKEY);
if( str.Find("R14") != -1)
{
pCmdUI->Enable(false);
}
else
{
pCmdUI->Enable(true);
}
}
else
{
pCmdUI->Enable(true);
}
}
catch(CException *e)
{
e->Delete();
}
catch(...)
{
AfxMessageBox("Error OnUpdateDrawZDj");
}
}
void CMainFrame::OnZdjDrawepHsy()
{
// TODO: Add your command handler code here
DrawZdjTab(iZDJDRAW705mmHSY);
}
void CMainFrame::OnMenuitemChangmaterial()
{
CChangMaterilName dlgMaterilName;
dlgMaterilName.DoModal();
// TODO: Add your command handler code here
}
void CMainFrame::OnZdjDrawepQgy()
{
// TODO: Add your command handler code here
DrawZdjTab(iZDJDRAW705mmQGY);
}
void CMainFrame::OnZdjHbyj()
{
// TODO: Add your command handler code here
DrawZdjTab(iZDJDRAW705mmHBYZ );
}
//
//从支吊架中导出已经计算后的数据到AutoIPED(保温油漆)
void CMainFrame::OnPhsToAutoiped()
{
EDIBgbl::strExportPaint = "c:\\prjdb4.0\\"; //又作为状态变量,
CExportPaint Paint;
if( !Paint.GetIPEDPath() )
{
AfxMessageBox("当前机器没有安装AutoIPED软件!");
}
else
{
SumCL( 2 );
Paint.StartupAutoIPED();
}
EDIBgbl::strExportPaint = "";
}
// LFX 加 2005.2.26
void CMainFrame::OnCommdboper()
{
// TODO: Add your command handler code here
CDlgDBOper dlgDBOper;
dlgDBOper.DoModal();
//if(dlgDBOper.m_hWnd==NULL)
//{
//dlgDBOper.Create(IDD_DLG_DBOPER,NULL);
// dlgDBOper.DoModal();
//}
//dlgDBOper.ShowWindow(SW_SHOWNORMAL );
//dlgDBOper.SetWindowPos(&wndTop,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
}
//END LFX 加 2005.2.26
//pfg20050601
void CMainFrame::OnZdjAdrawbjhy()
{
DrawZdjTab(iZDJDRAWBJHY01);
}
void CMainFrame::OnZdjBdrawbjhy()
{
DrawZdjTab(iZDJDRAWBJHY02);
}
void CMainFrame::OnMENUImportAutoPHS()
{
}
void CMainFrame::OnPlantvisionToPhs()
{
CImportPlantVision pv;
if ( IDOK == pv.DoModal() )
{
ReadResult_Excel(FrmTxsr.m_pViewTxsr->m_ActiveRs);
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/uesoft/AutoPHS.git
git@gitee.com:uesoft/AutoPHS.git
uesoft
AutoPHS
AutoPHS
CAE

搜索帮助