⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 guestor.cpp

📁 该系统为花店销售管理系统
💻 CPP
字号:
// guestor.cpp : implementation file
//

#include "stdafx.h"
#include "flowerSaleSystem.h"
#include "guestor.h"
#include "price.h"
#include "warehouse.h"
#include "gusename.h"
#include "gusepr.h"
#include "orflin.h"
#include "gusepr.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

extern CString m_iden;
/////////////////////////////////////////////////////////////////////////////
// guestor property page

IMPLEMENT_DYNCREATE(guestor, CPropertyPage)

guestor::guestor() : CPropertyPage(guestor::IDD)
{
	//{{AFX_DATA_INIT(guestor)
	m_amount = 0;
	m_nIndex=-1;
	m_days = 0;
	//}}AFX_DATA_INIT
}

guestor::~guestor()
{
}

void guestor::DoDataExchange(CDataExchange* pDX)
{
	CPropertyPage::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(guestor)
	DDX_Control(pDX, IDC_LIST1, m_list);
	DDX_Text(pDX, IDC_EDITamount, m_amount);
	DDX_Text(pDX, IDC_EDITdays, m_days);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(guestor, CPropertyPage)
	//{{AFX_MSG_MAP(guestor)
	ON_BN_CLICKED(IDC_BUTTONname, OnBUTTONname)
	ON_BN_CLICKED(IDC_BUTTONprice, OnBUTTONprice)
	ON_BN_CLICKED(IDC_BUTTONorder, OnBUTTONorder)
	ON_WM_PAINT()
	ON_WM_CTLCOLOR()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// guestor message handlers

BOOL guestor::OnInitDialog() 
{
	CPropertyPage::OnInitDialog();
	
	// TODO: Add extra initialization here
	m_list.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);
	m_list.SetBkColor(RGB(247,247,255));
	m_list.SetTextColor(RGB(0,0,255));
	m_list.SetTextBkColor(RGB(247,247,255));
	
	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_list.SetFont(&m_font);
	m_list.InsertColumn(0,"花号",LVCFMT_CENTER,80);
	m_list.InsertColumn(1,"花名",LVCFMT_CENTER,80);
	m_list.InsertColumn(2,"零售价",LVCFMT_CENTER,60);
	m_list.InsertColumn(3,"批发价",LVCFMT_CENTER,60);
	m_list.InsertColumn(4,"折扣",LVCFMT_CENTER,50);
	m_list.InsertColumn(5,"折后零售价",LVCFMT_CENTER,100);
	m_list.InsertColumn(6,"折后批发价",LVCFMT_CENTER,100);
    m_brush.CreateSolidBrush(RGB(0,0,0));
    m_list.DeleteAllItems();
	warehouse wa;
	int n=0;
	if(wa.Open())
	{
		while(!wa.IsEOF())
		{
			m_list.InsertItem(n,"");
			m_list.SetItemText(n,0,wa.m_wid);
		    m_list.SetItemText(n,1,wa.m_wnaem);
        	price pr;
			CString s;
			s=wa.m_wid;
			pr.m_strFilter.Format("fid='%s'",s);
			if(pr.Open())
			{
				if(!pr.IsEOF())
				{
                    s.Format("%g",pr.m_retailPrice);
					m_list.SetItemText(n,2,s);
					s.Format("%g",pr.m_wholesalePrice);
					m_list.SetItemText(n,3,s);
					s.Format("%g",pr.m_fdiscount);
					m_list.SetItemText(n,4,s);
					s.Format("%g",pr.m_fdiscount*pr.m_retailPrice);
					m_list.SetItemText(n,5,s);
					s.Format("%g",pr.m_fdiscount*pr.m_wholesalePrice);
					m_list.SetItemText(n,6,s);						
				}
			}
			pr.Close();
			n++;
			wa.MoveNext();
		}
	}
	wa.Close();
	m_amount=1;
	m_days=20;

	UpdateData(FALSE);
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void guestor::OnBUTTONname() 
{
	// TODO: Add your control notification handler code here
	gusename mydlg;
	if(mydlg.DoModal()==IDOK)
	{
        m_list.DeleteAllItems();
		warehouse wa;
		int n=0;
		wa.m_strFilter.Format("wnaem='%s'",mydlg.m_name);
		if(wa.Open())
		{
			while(!wa.IsEOF())
			{
				m_list.InsertItem(n,"");
				m_list.SetItemText(n,0,wa.m_wid);
				m_list.SetItemText(n,1,wa.m_wnaem);
				price pr;
				CString s;
				s=wa.m_wid;
				pr.m_strFilter.Format("fid='%s'",s);
				if(pr.Open())
				{
					if(!pr.IsEOF())
					{
						s.Format("%g",pr.m_retailPrice);
						m_list.SetItemText(n,2,s);
						s.Format("%g",pr.m_wholesalePrice);
						m_list.SetItemText(n,3,s);
						s.Format("%g",pr.m_fdiscount);
						m_list.SetItemText(n,4,s);
						s.Format("%g",pr.m_fdiscount*pr.m_retailPrice);
						m_list.SetItemText(n,5,s);
						s.Format("%g",pr.m_fdiscount*pr.m_wholesalePrice);
						m_list.SetItemText(n,6,s);						
					}
				}
				pr.Close();
				n++;
				wa.MoveNext();
			}
		}
	wa.Close();
	}
}

void guestor::OnBUTTONprice() 
{
	// TODO: Add your control notification handler code here
	gusepr mydlg;
	if(mydlg.DoModal()==IDOK)
	{
        m_list.DeleteAllItems();
		warehouse wa;
		int n=0;
		if(wa.Open())
		{
			while(!wa.IsEOF())
			{
				m_list.InsertItem(n,"");
				//m_list.SetItemText(n,0,wa.m_wid);
				//m_list.SetItemText(n,1,wa.m_wnaem);
				price pr;
				CString s;
				s=wa.m_wid;
				pr.m_strFilter.Format("fid='%s'",s);
				if(pr.Open())
				{
					if(!pr.IsEOF())
					{
						if(pr.m_retailPrice>=mydlg.m_min&&pr.m_retailPrice<=mydlg.m_max)
						{
                            m_list.SetItemText(n,0,wa.m_wid);
							m_list.SetItemText(n,1,wa.m_wnaem);
							
							s.Format("%g",pr.m_retailPrice);
							m_list.SetItemText(n,2,s);
							s.Format("%g",pr.m_wholesalePrice);
							m_list.SetItemText(n,3,s);
							s.Format("%g",pr.m_fdiscount);
							m_list.SetItemText(n,4,s);
							s.Format("%g",pr.m_fdiscount*pr.m_retailPrice);
							m_list.SetItemText(n,5,s);
							s.Format("%g",pr.m_fdiscount*pr.m_wholesalePrice);
						    m_list.SetItemText(n,6,s);	
							n++;
						}
										
					}
				}
				pr.Close();
				
				wa.MoveNext();
			}
		}
	wa.Close();
	}
}

void guestor::OnBUTTONorder() 
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
	m_list.SetFocus();
	POSITION pos = m_list.GetFirstSelectedItemPosition();
	m_nIndex = m_list.GetNextSelectedItem(pos);  // 得到项目索引
	if(m_nIndex==-1)
	{
		
		MessageBox("请选择一项再订购!","提示",MB_ICONINFORMATION);
		return;
	}
	
	CString m_getmid;
	orflin m_set;
	int n=0;
	CTime tm;
    tm=CTime::GetCurrentTime();
	m_getmid=m_list.GetItemText(m_nIndex,0);
	if(m_set.Open())
	{
		while(!m_set.IsEOF())
		{
            n++;
			m_set.MoveNext();
		}
		m_set.AddNew();
		m_set.m_oid.Format("%d",1001+n);
		m_set.m_gid=m_iden;
		m_set.m_fid=m_getmid;
		m_set.m_amount=m_amount;
        m_set.m_orderDate=tm;
        m_set.m_inDays=m_days;
		m_set.m_state=0;
		price pr;
		pr.m_strFilter.Format("fid='%s'",m_getmid);
		if(pr.Open())
			m_set.m_salePrice=m_amount<100?pr.m_retailPrice*pr.m_fdiscount:pr.m_wholesalePrice*pr.m_fdiscount;
		pr.Close();
	}
	double pri;
	pri=m_set.m_salePrice*m_amount;
	m_set.Update();
	m_set.Requery();
    m_set.MoveLast();
	m_set.Close();
	m_getmid=m_list.GetItemText(m_nIndex,1);
	CString s;
	s="你将购买";
	s.Format("你已购买%d朵%s,共花费您%g元.",m_amount,m_getmid,pri);
	MessageBox(s,"确认信息",MB_ICONEXCLAMATION|MB_OK);
    
}


void guestor::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	
	CDC     memDC;
	CBitmap	bitmap;
	BITMAP  bmp;
	bitmap.LoadBitmap(IDB_BITMAPg);
	bitmap.GetObject (sizeof(BITMAP),&bmp);
	memDC.CreateCompatibleDC (&dc);
	memDC.SelectObject (bitmap);
		dc.BitBlt (0,0,bmp.bmWidth ,bmp.bmHeight ,&memDC,0,0,SRCCOPY);
	
	// Do not call CPropertyPage::OnPaint() for painting messages
}

HBRUSH guestor::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
{
	HBRUSH hbr = CPropertyPage::OnCtlColor(pDC, pWnd, nCtlColor);
	
	
	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;   
	}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 + -