📄 flowersalesystemdlg.cpp
字号:
// flowerSaleSystemDlg.cpp : implementation file
//
#include "stdafx.h"
#include "flowerSaleSystem.h"
#include "flowerSaleSystemDlg.h"
#include "deset.h"
#include "guset.h"
#include "sudelog.h"
#include "codelog.h"
#include "guestlog.h"
#include "touristlog.h"
#include <mmsystem.h> // PlaySound()
#pragma comment(lib,"winmm.lib")
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern CString m_iden;
/////////////////////////////////////////////////////////////////////////////
// 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()
/////////////////////////////////////////////////////////////////////////////
// CFlowerSaleSystemDlg dialog
CFlowerSaleSystemDlg::CFlowerSaleSystemDlg(CWnd* pParent /*=NULL*/)
: CDialog(CFlowerSaleSystemDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CFlowerSaleSystemDlg)
m_user = _T("");
m_psw = _T("");
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CFlowerSaleSystemDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CFlowerSaleSystemDlg)
DDX_Control(pDX, IDC_STATICt, m_jumpyDraw);
DDX_Control(pDX, IDC_COMBO1, m_combo);
DDX_Text(pDX, IDC_EDIT_user, m_user);
DDX_Text(pDX, IDC_EDITpsw, m_psw);
DDX_Control(pDX, IDC_BUTTONexit, m_btt);
DDX_Control(pDX, IDC_BUTTONenter, m_btr);
//}}AFX_DATA_MAP
}
UINT Thread(LPVOID lparam)
{
PlaySound("loveheart.wav", NULL, 1);
return 0;
}
BEGIN_MESSAGE_MAP(CFlowerSaleSystemDlg, CDialog)
//{{AFX_MSG_MAP(CFlowerSaleSystemDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTONenter, OnBUTTONenter)
ON_BN_CLICKED(IDC_BUTTONexit, OnBUTTONexit)
ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1)
ON_WM_TIMER()
ON_WM_CTLCOLOR()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CFlowerSaleSystemDlg message handlers
BOOL CFlowerSaleSystemDlg::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);
}
}
// 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
m_font.CreateFont(16, 0,0,0,FW_NORMAL, 0,0,0,
DEFAULT_CHARSET, OUT_CHARACTER_PRECIS, CLIP_CHARACTER_PRECIS,
DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Georgia");
m_stcDanger.SubclassDlgItem(IDC_DANGER, this);
m_stcDanger.SetBlinkBkColors(RGB(128, 0, 0), RGB(255,0,0));
SetTimer(0,1000,NULL);
m_stcDanger.StartBkBlink(TRUE, CColorStaticST::ST_FLS_FAST);
m_stcDanger.SetBlinkTextColors(RGB(128,0,0), RGB(255,255,255));
m_stcDanger.StartTextBlink(TRUE, CColorStaticST::ST_FLS_FAST);
m_stcDanger.SetFont(&m_font);
m_stcDanger.EnableNotify(this, WM_USER + 10);
//m_btr.SetBkMode (false);
m_btr.SetNormalTextColor (RGB(0,0,255));
m_btr.SetActiveTextColor (RGB(0,255,0));
//m_btr.SetStyle ();
//m_btt.SetBkMode (false);
m_btt.SetNormalTextColor (RGB(0,0,255));
m_btt.SetActiveTextColor (RGB(0,255,0));
//m_btt.SetStyle ();
m_combo.SetCurSel(0);
SetWindowText("花店销售管理系统Bata 1.0");
m_brush.CreateSolidBrush(RGB(0,0,0));
::AfxBeginThread(Thread,this);
return TRUE; // return TRUE unless you set the focus to a control
}
void CFlowerSaleSystemDlg::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 CFlowerSaleSystemDlg::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();
CClientDC dc(this);
CDC memDC;
CBitmap bitmap;
BITMAP bmp;
bitmap.LoadBitmap(IDB_BITMAP_BACK);
bitmap.GetObject (sizeof(BITMAP),&bmp);
memDC.CreateCompatibleDC (&dc);
memDC.SelectObject (bitmap);
dc.BitBlt (0,0,bmp.bmWidth ,bmp.bmHeight ,&memDC,0,0,SRCCOPY);
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CFlowerSaleSystemDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CFlowerSaleSystemDlg::OnBUTTONenter()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
this->CloseWindow();
m_iden=m_user;
m_combo.GetLBText(m_combo.GetCurSel(),m_getstr);
if(m_getstr=="游客")
{
touristlog tolog;
tolog.DoModal();
}
else if(m_getstr=="顾客")
{
guset gu;
gu.m_strFilter.Format("gid='%s'",m_user);
if(gu.Open())
{
if(m_user=="")
{
MessageBox("请输入账号!","温馨提示");
return;
}
if(gu.IsEOF())
{
MessageBox("没有此账号,请重新输入.","温馨提示");
return;
}
while(m_psw.GetLength()<6)m_psw+=" ";
if(gu.m_gpassword==m_psw)
{
/*gu.Edit();
CTime tm=CTime::GetCurrentTime();;
gu.m_glastlandingTime=tm;
gu.Update();
gu.Requery();*/
guestlog gulog;
gulog.DoModal();
}
else if(m_psw=="")MessageBox("请输入密码!","温馨提示");
else MessageBox("密码错误,请重新输入","温馨提示");
}
gu.Close();
}
else
{
deset de;
de.m_strFilter.Format("mid='%s'",m_user);
if(de.Open())
{
if(m_user=="")
{
MessageBox("请输入账号!","温馨提示");
return;
}
if(de.IsEOF())
{
MessageBox("没有账号,请重新输入","温馨提示");
return;
}
while(m_psw.GetLength()<6)m_psw+=" ";
if(de.m_mpassword==m_psw)
{
if(de.m_mpower=="超级")
{
sudelog sudlg;
sudlg.DoModal();
}
else
{
codelog codlg;
codlg.DoModal();
}
}
else if(m_psw=="")MessageBox("请输入密码!","温馨提示");
else MessageBox("密码错误,请重新输入","温馨提示");
}
de.Close();
}
}
void CFlowerSaleSystemDlg::OnBUTTONexit()
{
// TODO: Add your control notification handler code here
OnOK();
}
void CFlowerSaleSystemDlg::OnSelchangeCombo1()
{
// TODO: Add your control notification handler code here
m_combo.GetLBText(m_combo.GetCurSel(),m_getstr);
CWnd *cwd1,*cwd2;
cwd1=GetDlgItem(IDC_EDIT_user);
cwd2=GetDlgItem(IDC_EDITpsw);
if(m_getstr=="游客")
{
cwd1->EnableWindow(FALSE);
cwd2->EnableWindow(FALSE);
}
else
{
cwd1->EnableWindow(TRUE);
cwd2->EnableWindow(TRUE);
}
m_psw=m_user="";
UpdateData(FALSE);
}
void CFlowerSaleSystemDlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
m_jumpyDraw.StartJumpyText("Hua Yuehen's Work,2009.02.26",
1000, "MS Sans Serif", 24, RGB(0, 255, 0), RGB(0, 0, 0),
RGB(123, 158, 198), RGB(0,0,255));
CDialog::OnTimer(nIDEvent);
}
HBRUSH CFlowerSaleSystemDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
if(nCtlColor==CTLCOLOR_LISTBOX)
{
pDC->SetBkMode(TRANSPARENT);//
pDC->SetTextColor(RGB(255,0,0));
return m_brush;
}
if(nCtlColor==CTLCOLOR_EDIT)
{
pDC->SetBkMode(TRANSPARENT);//
pDC->SetTextColor(RGB(0,255,0));
return m_brush;
}
if(nCtlColor==CTLCOLOR_STATIC)
{
pDC->SetBkMode(TRANSPARENT);//
pDC->SetTextColor(RGB(255,255,0));
return m_brush
;
}
if(nCtlColor==CTLCOLOR_DLG)
{
pDC->SetBkMode(TRANSPARENT);//
pDC->SetTextColor(RGB(175,216,229)); //浅色字体
return hbr;
}
// TODO: Return a different brush if the default is not desired
return hbr;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -