📄 lmts.cpp
字号:
// LMTS.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "LMTS.h"
#include "LMTSDlg.h"
#include "odbcinst.h"
#include "student_form.h"
#include "teacher_form.h"
#include "manager_form.h"
#include "admin_form.h"
#include "REG.h"
#include "user.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CLMTSApp
BEGIN_MESSAGE_MAP(CLMTSApp, CWinApp)
//{{AFX_MSG_MAP(CLMTSApp)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG
ON_COMMAND(ID_HELP, CWinApp::OnHelp)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CLMTSApp construction
CLMTSApp::CLMTSApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CLMTSApp object
CLMTSApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CLMTSApp initialization
BOOL CLMTSApp::InitInstance()
{
AfxEnableControlContainer();
SetDialogBkColor(RGB(200,223,200),RGB(0,0,255));
CString sPath;
GetModuleFileName(NULL,sPath.GetBufferSetLength(MAX_PATH+1),MAX_PATH);
sPath.ReleaseBuffer ();
int nPos;
nPos=sPath.ReverseFind ('\\');
sPath=sPath.Left (nPos);
nPos=sPath.ReverseFind('\\');
sPath=sPath.Left (nPos);
CString lpszFile = sPath + "\\LMTS.mdb";
char* szDesc;
int mlen;
szDesc=new char[256];
sprintf(szDesc,"DSN=%s? DESCRIPTION=TOC support source? DBQ=%s? FIL=MicrosoftAccess? DEFAULTDIR=%s?? ","LMTS",lpszFile,sPath);
mlen = strlen(szDesc);
for (int i=0; i<mlen; i++)
{
if (szDesc[i] == '?')
szDesc[i] = '\0';
}
SQLConfigDataSource(NULL,ODBC_ADD_DSN,"Microsoft Access Driver (*.mdb)\0",(LPCSTR)szDesc);
// 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.
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
LoadStdProfileSettings();
CString login_id,login_psw,flag;
CLMTSDlg dlg;
user login_user;
while (dlg.DoModal()==IDOK)
{
flag="false";
login_user.Open();
login_user.MoveFirst();
while(!login_user.IsEOF()){
login_id=login_user.m_id;
login_psw=login_user.m_password;
if((dlg.input_id==login_id) && (dlg.input_password==login_psw))
{
flag="true";
if(login_user.m_regist!="yes")
{
AfxMessageBox("未通过注册");
break;
}
AfxMessageBox("欢迎使用LTMS");
if(login_user.m_property=="student")
{
student_form stu_form;
stu_form.user_id=login_id;
stu_form.DoModal();
}
if(login_user.m_property=="admin")
{
admin_form adm_form;
adm_form.DoModal();
}
if(login_user.m_property=="teacher")
{
teacher_form tea_form;
tea_form.user_id=login_id;
tea_form.DoModal();
}
if(login_user.m_property=="manager")
{
manager_form man_form;
man_form.DoModal();
}
login_user.Close();
return TRUE;
}
login_user.MoveNext();
}
if(flag=="false")
{
AfxMessageBox("请输入正确用户名和密码");
}
dlg.input_id.Empty();
dlg.input_password.Empty();
login_user.Close();
//}while((dlg.input_id!=login_id) || (dlg.input_password!=login_psw));
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
/*if(dlg.DoModal()==IDCANCEL)
{
AfxMessageBox("请输入用户名"); // TODO: Place code here to handle when the dialog is
// dismissed with Cancel
//dlg.DoModal();
}
*/
// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -