📄 mestang.cpp
字号:
// MESTang.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "MESTang.h"
#include "MainFrm.h"
#include "LogDlg.h"
#include "FeedFormView.h"
#include "MessageView.h"
#include "Aquiesce_FormView.h"
#include "SlabInputFormView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
//DATABASE_TRAC database;
/////////////////////////////////////////////////////////////////////////////
// CMESTangApp
const UINT ID_RA_MSG =::RegisterWindowMessage(ra_MSG);
BEGIN_MESSAGE_MAP(CMESTangApp, CWinApp)
//{{AFX_MSG_MAP(CMESTangApp)
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
ON_COMMAND(ID_FILE_NEW, OnFileNew)
ON_COMMAND(ID_SYS_DISCONNECT, OnSysDisconnect)
ON_UPDATE_COMMAND_UI(ID_SYS_DISCONNECT, OnUpdateSysDisconnect)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMESTangApp construction
CMESTangApp::CMESTangApp()
{
// TODO: add construction code here,
FLAG=-1;
message_str=_T("");
// Place all significant initialization in InitInstance
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CMESTangApp object
CMESTangApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CMESTangApp initialization
BOOL CMESTangApp::InitInstance()
{
AfxEnableControlContainer();
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
m_hOneInstance = ::CreateMutex( NULL,FALSE,UNIQE_NAME);
if ( GetLastError() == ERROR_ALREADY_EXISTS )
{
DWORD dwRecipients = BSM_APPLICATIONS;
::BroadcastSystemMessage( BSF_NOHANG,&dwRecipients,
ID_RA_MSG, // registered window message
0,0 ); // user defined parameters
return FALSE;
}
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
// Change the registry key under which our settings are stored.
// TODO: You should modify this string to be something appropriate
// such as the name of your company or organization.
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
// To create the main window, this code creates a new frame window
// object and then sets it as the application's main window object.
CMDIFrameWnd* pFrame = new CMainFrame;
m_pMainWnd = pFrame;
// create main MDI frame window
if (!pFrame->LoadFrame(IDR_MAINFRAME))
return FALSE;
// try to load shared MDI menus and accelerator table
//TODO: add additional member variables and load calls for
// additional menu types your application may need.
HINSTANCE hInst = AfxGetResourceHandle();
m_hMDIMenu = ::LoadMenu(hInst, MAKEINTRESOURCE(IDR_MESTANTYPE));
m_hMenu=::LoadMenu(hInst, MAKEINTRESOURCE(IDR_MAINFRAME));//加载菜单
m_hMDIAccel = ::LoadAccelerators(hInst, MAKEINTRESOURCE(IDR_MESTANTYPE));
// The main window has been initialized, so show and update it.
pFrame->ShowWindow(SW_SHOWMAXIMIZED);
pFrame->SetWindowText("MES_SLAB");
// pFrame->ShowWindow(m_nCmdShow);
pFrame->UpdateWindow();
m_candisconnect=false;
m_bmp1.LoadBitmap(IDB_BITMAP1);
m_bmp2.LoadBitmap(IDB_BITMAP2);
m_bmp3.LoadBitmap(IDB_BITMAP3);
m_bmp4.LoadBitmap(IDB_BITMAP4);
m_event=new MUL_EVENT(false);
CLogDlg dlg;
if(dlg.DoModal()!=IDOK)
return TRUE;
else
{
SetMenu(AfxGetMainWnd()->m_hWnd,m_hMDIMenu);
m_candisconnect=true;
m_pMainWnd->SetWindowText("MES_SLAB");
((CMainFrame*)m_pMainWnd)->SetToolBarShow();
int cx=GetSystemMetrics(SM_CXMENUCHECK);
int cy=GetSystemMetrics(SM_CYMENUCHECK);
CMenu *pMenu=AfxGetMainWnd()->GetMenu();
CMenu *pSubMenu=pMenu->GetSubMenu(1);
pSubMenu->SetMenuItemBitmaps(0,MF_BYPOSITION,&m_bmp1,&m_bmp1);
pSubMenu->SetMenuItemBitmaps(2,MF_BYPOSITION,&m_bmp2,&m_bmp2);
pSubMenu=pMenu->GetSubMenu(4);
pSubMenu->SetMenuItemBitmaps(0,MF_BYPOSITION,&m_bmp3,&m_bmp3);
pSubMenu=pMenu->GetSubMenu(5);
pSubMenu->SetMenuItemBitmaps(ID_APP_ABOUT,MF_BYCOMMAND,&m_bmp4,&m_bmp4);
return TRUE;
}
}
/////////////////////////////////////////////////////////////////////////////
// CMESTangApp message handlers
int CMESTangApp::ExitInstance()
{
if (m_hMDIMenu != NULL)
FreeResource(m_hMDIMenu);
if (m_hMDIAccel != NULL)
FreeResource(m_hMDIAccel);
delete m_event;
CloseHandle(m_hOneInstance);
return CWinApp::ExitInstance();
}
void CMESTangApp::OnFileNew() //登录
{
CLogDlg dlg;
if(dlg.DoModal()!=IDOK)
return;
SetMenu(AfxGetMainWnd()->m_hWnd,m_hMDIMenu);
m_candisconnect=true;
m_pMainWnd->SetWindowText("MES_SLAB");
((CMainFrame*)m_pMainWnd)->SetToolBarShow();
int cx=GetSystemMetrics(SM_CXMENUCHECK);
int cy=GetSystemMetrics(SM_CYMENUCHECK);
CMenu *pMenu=AfxGetMainWnd()->GetMenu();
CMenu *pSubMenu=pMenu->GetSubMenu(1);
pSubMenu->SetMenuItemBitmaps(0,MF_BYPOSITION,&m_bmp1,&m_bmp1);
pSubMenu->SetMenuItemBitmaps(2,MF_BYPOSITION,&m_bmp2,&m_bmp2);
pSubMenu=pMenu->GetSubMenu(4);
pSubMenu->SetMenuItemBitmaps(0,MF_BYPOSITION,&m_bmp3,&m_bmp3);
pSubMenu=pMenu->GetSubMenu(5);
pSubMenu->SetMenuItemBitmaps(ID_APP_ABOUT,MF_BYCOMMAND,&m_bmp4,&m_bmp4);
}
void CMESTangApp::OnSysDisconnect() //注销
{
CMainFrame* fPrm;
fPrm=(CMainFrame*)AfxGetMainWnd();
fPrm->m_SplitterFirst.SwitchView(11,0,0);
SetMenu (AfxGetMainWnd()->m_hWnd,m_hMenu);
m_candisconnect=false;
m_pMainWnd->SetWindowText("MES_SLAB");
((CMainFrame*)m_pMainWnd)->SetToolBarHide();
if (cn.is_opened==true)
{
cn.close();
}
else
{
}
CLogDlg dlg;
if (dlg.DoModal()==IDOK)
{
SetMenu(AfxGetMainWnd()->m_hWnd,m_hMDIMenu);
m_candisconnect=true;
m_pMainWnd->SetWindowText("MES_SLAB");
((CMainFrame*)m_pMainWnd)->SetToolBarShow();
int cx=GetSystemMetrics(SM_CXMENUCHECK);
int cy=GetSystemMetrics(SM_CYMENUCHECK);
CMenu *pMenu=AfxGetMainWnd()->GetMenu();
CMenu *pSubMenu=pMenu->GetSubMenu(1);
pSubMenu->SetMenuItemBitmaps(0,MF_BYPOSITION,&m_bmp1,&m_bmp1);
pSubMenu->SetMenuItemBitmaps(2,MF_BYPOSITION,&m_bmp2,&m_bmp2);
pSubMenu=pMenu->GetSubMenu(4);
pSubMenu->SetMenuItemBitmaps(0,MF_BYPOSITION,&m_bmp3,&m_bmp3);
pSubMenu=pMenu->GetSubMenu(5);
pSubMenu->SetMenuItemBitmaps(ID_APP_ABOUT,MF_BYCOMMAND,&m_bmp4,&m_bmp4);
}
}
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
// No message handlers
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
// App command to run the dialog
void CMESTangApp::OnAppAbout()
{
CAboutDlg aboutDlg;
aboutDlg.DoModal();
}
/////////////////////////////////////////////////////////////////////////////
// CMESTangApp message handlers
void CMESTangApp::OnUpdateSysDisconnect(CCmdUI* pCmdUI)
{
pCmdUI->Enable(m_candisconnect);
}
BOOL CMESTangApp::open_mes()
{
bool m_pcenec;
m_pcenec=true;
try
{
if (cn.is_opened==false)
{
cn.open("MESDB", "MES", "mes");
}
}
catch (oralib::error &e)
{
m_pcenec=false;
CString str;
str.Empty();
int num=e.details().size();
for (int i=0;i<num;i++)
{
str+=e.details()[i];
}
Msg(str);
}
if(m_pcenec)
{
return true;
}
else
{
MessageBox(AfxGetMainWnd()->m_hWnd,"未连接上数据库,请检查数据库","系统提示",MB_OK);
return false;
}
}
BOOL CMESTangApp::PreTranslateMessage(MSG* pMsg)
{
switch(pMsg->message)
{
case WM_UPDATE_SLAB:
Update_List();
break;
case WM_UPDATE_PLAN:
Update_Plan_List();
break;
}
return CWinApp::PreTranslateMessage(pMsg);
}
void CMESTangApp::Msg(CString str)
{
CMainFrame* fPrm;
fPrm=(CMainFrame*)AfxGetMainWnd();
CMessageView* pview=(CMessageView*)fPrm->m_SplitterSecond.GetPane(0,0);
SYSTEMTIME tm;
GetLocalTime(&tm);
CString time;
time.Format(_T(" %d年%2d月%2d日 %2d时:%2d分:%2d秒"), tm.wYear,tm.wMonth,tm.wDay,tm.wHour, tm.wMinute,tm.wSecond);
pview->m_list_message.AddString(time+" "+str);
int numList=pview->m_list_message.GetCount()-1;
pview->m_list_message.SetTopIndex(numList);
pview->m_list_message.SetCurSel(numList);
}
void CMESTangApp::MsgDel()
{
CMainFrame* fPrm;
fPrm=(CMainFrame*)AfxGetMainWnd();
CMessageView* pview=(CMessageView*)fPrm->m_SplitterFirst.GetPane(1,0);
int numList=pview->m_list_message.GetCount()-1;
pview->m_list_message.DeleteString(numList);
}
void CMESTangApp::Update_List()
{
if (message_str!=_T(""))
{
Msg(message_str);
}
if (cn.is_opened==false)
{
open_mes();
}
else
{
}
CMainFrame* fPrm;
fPrm=(CMainFrame*)AfxGetMainWnd();
CFeedFormView* pview=(CFeedFormView*)fPrm->m_SplitterFirst.GetViewPtr(12,0,0);
pview->m_cast.DeleteAllItems();
resultset &rs_cast = *(theApp.cn).select ("select * from CAST_INF");
SlabInfo_List_Update(pview->m_cast,rs_cast);
cn.close();
}
void CMESTangApp::Update_Plan_List()
{
if (cn.is_opened==false)
{
open_mes();
}
else
{
}
CMainFrame* fPrm;
fPrm=(CMainFrame*)AfxGetMainWnd();
CFeedFormView* pview=(CFeedFormView*)fPrm->m_SplitterFirst.GetViewPtr(12,0,0);
pview->m_plan.DeleteAllItems();
resultset &rs_plan_update = *(theApp.cn).select ("select * from PRODUCE_PLAN_TEMP order by MANUFACTURE_DATE desc,SHIFT desc,SHIFT_ID desc ");
Planlist_Update(pview->m_plan,rs_plan_update);
cn.close();
if (message_str!=_T(""))
{
Msg(message_str);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -