fOpen. WriteString («*****n»);
MessageBox («Saved to elec.txt», MB_OK);
}
MasKursDlg class
// MasKursDlg.cpp: implementation file
//
#include «stdafx.h»
#include «MasKurs.h»
#include «MasKursDlg.h»
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// 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)
// }} 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()
/////////////////////////////////////////////////////////////////////////////
// CMasKursDlg dialog
CMasKursDlg:CMasKursDlg (CWnd* pParent /*=NULL*/)
: CDialog (CMasKursDlg:IDD, pParent)
{
// {{AFX_DATA_INIT(CMasKursDlg)
// NOTE: the ClassWizard will add member initialization here
// }} AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon (IDR_MAINFRAME);
}
void CMasKursDlg: DoDataExchange (CDataExchange* pDX)
{
CDialog: DoDataExchange(pDX);
// {{AFX_DATA_MAP(CMasKursDlg)
DDX_Control (pDX, IDC_LIST1, m_list);
// }} AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP (CMasKursDlg, CDialog)
// {{AFX_MSG_MAP(CMasKursDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_COMMAND (ID_FILE_ACTION, OnFileAction)
ON_BN_CLICKED (IDC_BUTTON3, OnBrowse)
ON_BN_CLICKED (IDC_BUTTON1, OnButton1)
ON_BN_CLICKED (IDC_BUTTON2, OnButton2)
ON_COMMAND (ID_FILE_EXIT, OnFileExit)
ON_COMMAND (ID_ABOUT_SHOW, OnAboutShow)
// }} AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMasKursDlg message handlers
#include «login.h»
BOOL CMasKursDlg: OnInitDialog()
{
CDialog: OnInitDialog();
// Add «About…» menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT (IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu!= NULL)
{
CString strAboutMenu;
strAboutMenu. LoadString (IDS_ABOUTBOX);
if (! strAboutMenu. IsEmpty())
{
pSysMenu->AppendMenu (MF_SEPARATOR);
pSysMenu->AppendMenu (MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
login dlg;
dlg.m_login= «buhgalter»;
if (dlg. DoModal()==IDOK) {
if (dlg.m_pass== «111» && dlg.m_login== «buhgalter») {
return TRUE;
}
else {
MessageBox («Incorrect!!!»);
EndDialog(0);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon (m_hIcon, TRUE); // Set big icon
SetIcon (m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
void CMasKursDlg: OnSysCommand (UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout. DoModal();
}
else
{
CDialog: OnSysCommand (nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CMasKursDlg: OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage (WM_ICONERASEBKGND, (WPARAM) dc. GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics (SM_CXICON);
int cyIcon = GetSystemMetrics (SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect. Width() – cxIcon + 1) / 2;
int y = (rect. Height() – cyIcon + 1) / 2;
// Draw the icon
dc. DrawIcon (x, y, m_hIcon);
}
else
{
CDialog: OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CMasKursDlg: OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
#include «add.h»
void CMasKursDlg: OnFileAction()
{
add dlg;
dlg. DoModal();
}
void CMasKursDlg: OnBrowse()
{
CString str;
CString str1;
CFileDialog OpenFileDialog (true, «txt», NULL, OFN_FILEMUSTEXIST|OFN_HIDEREADONLY, «Text files (*.txt)|*.txt||»);
if (OpenFileDialog. DoModal()==IDOK) {
str=OpenFileDialog. GetPathName();
GetDlgItem (IDC_EDIT1)->SetWindowText(str);
CStdioFile fOpen (str, CFile:modeRead);
while (fOpen. ReadString(str)!=0) {
m_list. AddString(str);
}
}
}
void CMasKursDlg: OnButton1 ()
{
add dlg;
dlg. DoModal();
}
void CMasKursDlg: OnButton2 ()
{
EndDialog(0);
}
void CMasKursDlg: OnFileExit()
{
EndDialog(0);
}
void CMasKursDlg: OnAboutShow()
{
CAboutDlg dlg;
dlg. DoModal();
}
Path class
void path: OnShowWindow (BOOL bShow, UINT nStatus)
{
CDialog: OnShowWindow (bShow, nStatus);
UpdateData(TRUE);
CStdioFile fOpen («d:\MasKurs\driver.txt», CFile:modeRead);
CStdioFile fOpen1 («d:\MasKurs\konductor.txt», CFile:modeRead);
CString str;
CString str1;
while (fOpen. ReadString(str)!=0) {
m_combo. AddString(str);
}
while (fOpen1. ReadString(str1)!=0) {
m_combo1. AddString(str1);
}
// fOpen. SeekToEnd();
// fOpen. WriteString (m_date+»n»);
// fOpen. WriteString (m_number+»n»);
// fOpen. WriteString (m_marsh+»n»);
// fOpen. WriteString («*****"+»n»);
}
CString str1;
CString str2;
void path: OnSaveToPath()
{
UpdateData(TRUE);
CStdioFile fOpen («d:\MasKurs\path.txt», CFile:modeWrite);
CString str;
int index=m_combo. GetCurSel();
int index1=m_combo1. GetCurSel();
if (m_date==»» || m_number==»») {
MessageBox («Please fill all fields», «Info», MB_OK);
return;
}
m_combo. GetLBText (index, str1);
m_combo1. GetLBText (index1, str2);
fOpen. SeekToEnd();
fOpen. WriteString («FIO driver «+str1+»n»);
fOpen. WriteString («FIO konductor «+str2+»n»);
fOpen. WriteString («Date «+m_date+»n»);
fOpen. WriteString («Number «+m_number+»n»);
fOpen. WriteString («*****n»);
MessageBox («Saved to path.txt», MB_OK);
}
void path: OnBeginMarshrute()
{
UpdateData(TRUE);
CStdioFile fOpen («d:\MasKurs\marshrutebegin.txt», CFile:modeWrite);
CString str;
if (m_date1==»» || m_number1==»» || m_time==»») {
MessageBox («Please fill all fields», «Info», MB_OK);
return;
}
fOpen. SeekToEnd();
fOpen. WriteString («Date «+m_date1+»n»);
fOpen. WriteString («Number «+m_number1+»n»);
fOpen. WriteString («Time «+m_time+»n»);
fOpen. WriteString («*****n»);
MessageBox («Saved to marshrutebegin.txt», MB_OK);
}
void path: OnSaveToMarshruteOkonchanie()
{
UpdateData(TRUE);
CStdioFile fOpen («d:\MasKurs\marshruteokonchanie.txt», CFile:modeWrite);
CString str;
if (m_date2=»» || m_number2==»» || m_time1==»») {
MessageBox («Please fill all fields», «Info», MB_OK);
return;
}
fOpen. SeekToEnd();
fOpen. WriteString («Date «+m_date2+»n»);
fOpen. WriteString («Number «+m_number2+»n»);
fOpen. WriteString («Time «+m_time1+»n»);
fOpen. WriteString («*****n»);
MessageBox («Saved to marshruteokonchanie.txt», MB_OK);
}
Uch class
void uch: OnSaveToUchet()
{
UpdateData(TRUE);
CStdioFile fOpen («d:\MasKurs\uchet.txt», CFile:modeWrite);
CString str;
fOpen. SeekToEnd();
fOpen. WriteString («Date «+m_date+»n»);
fOpen. WriteString («Number of tickets «+m_number+»n»);
fOpen. WriteString («Nomer «+m_marsh+»n»);
fOpen. WriteString («*****n»);
MessageBox («Saved to uchet.txt», MB_OK);
}
8-09-2015, 14:27