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

📄 dsell.cpp

📁 商品销售管理系统程序全套源码 gongnengxiangjin
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// DSell.cpp : implementation file
//

#include "stdafx.h"
#include "商品销售管理系统.h"
#include "DSell.h"
#include "RxEdit.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#include "MyDoc.h"
#include "MainPrint.h"  
#include "MyView.h"
#include "externDllHeader.h"


/////////////////////////////////////////////////////////////////////////////
// CDSell dialog


CDSell::CDSell(CWnd* pParent /*=NULL*/)
	: CDialog(CDSell::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDSell)
	//}}AFX_DATA_INIT
}


void CDSell::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDSell)
	DDX_Control(pDX, IDC_STAGIVECHANGE, m_StaGiveChange);
	DDX_Control(pDX, IDC_STANOTPAY, m_StaNotPay);
	DDX_Control(pDX, IDC_EDTPAY, m_EdtPay);
	DDX_Control(pDX, IDC_COMSTYLE, m_ComStyle);
	DDX_Control(pDX, IDC_EDTDEALMAN, m_EdtDealMan);
	DDX_Control(pDX, IDC_STASumNumber, m_StaSumNumber);
	DDX_Control(pDX, IDC_STASmallSum, m_StaSmallSum);
	DDX_Control(pDX, IDC_STAID, m_StaID);
	DDX_Control(pDX, IDC_STABigSum, m_StaBigSum);
	DDX_Control(pDX, IDC_STADate, m_StaDate);
	DDX_Control(pDX, IDC_List, m_Grid);
	DDX_Control(pDX, IDC_EDTCLIECT, m_EdtCliect);
	DDX_Control(pDX, IDC_COMRID, m_ComRID);
	DDX_Control(pDX, IDC_BUTPrint, m_ButPrint);
	DDX_Control(pDX, IDC_BUTUndo, m_ButUndo);
	DDX_Control(pDX, IDC_BUTSave, m_ButSave);
	DDX_Control(pDX, IDC_BUTExit, m_ButExit);
	DDX_Control(pDX, IDC_BUTCleck, m_ButCleck);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDSell, CDialog)
	//{{AFX_MSG_MAP(CDSell)
	ON_WM_PAINT()
	ON_BN_CLICKED(IDC_BUTCleck, OnBUTCleck)
	ON_CBN_KILLFOCUS(IDC_COMRID, OnKillfocusComrid)
	ON_BN_CLICKED(IDC_BUTPrint, OnBUTPrint)
	ON_BN_CLICKED(IDC_BUTSave, OnBUTSave)
	ON_CBN_SETFOCUS(IDC_COMRID, OnSetfocusComrid)
	ON_CBN_KILLFOCUS(IDC_COMSTYLE, OnKillfocusComstyle)
	ON_BN_CLICKED(IDC_BUTUndo, OnBUTUndo)
	ON_BN_CLICKED(IDC_BUTExit, OnBUTExit)
	ON_WM_CTLCOLOR()
	ON_EN_CHANGE(IDC_EDTPAY, OnChangeEdtpay)
	//}}AFX_MSG_MAP
	ON_MESSAGE(DIY_KILLFOCUS,OnCellKillFocus)
	ON_MESSAGE(DIY_SETFOCUS,OnCellSetFocus)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDSell message handlers

void CDSell::OnOK() 
{
	// TODO: Add extra validation here
	
	//CDialog::OnOK();
}

void CDSell::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	
	CDC MemDC;
	CBitmap * pbit,bit;
	CRect rect;
	bit.LoadBitmap(IDB_BITMAP4);
	MemDC.CreateCompatibleDC(this->GetDC());
	pbit=MemDC.SelectObject(&bit);
	this->GetClientRect(&rect);
	dc.BitBlt(0,0,rect.Width(),rect.Height(),&MemDC,0,0,SRCCOPY);   
	MemDC.DeleteDC();
	::DeleteObject(&bit);
	::DeleteObject(pbit);	
	// Do not call CDialog::OnPaint() for painting messages
}

void CDSell::clear()
{
	this->m_StaBigSum.SetWindowText("零元");
	this->m_StaSmallSum.SetWindowText("0");
	this->m_StaSumNumber.SetWindowText("0");
	m_Grid.DeleteAllItems();
}

void CDSell::OnBUTCleck() 
{
	CTime time;
	CString cTime,NewID;
	this->Enabled(true);
	this->m_EdtCliect.SetFocus();
	NewID=ado.AutoNumber("销售信息表","票号","XS",3);
	this->m_StaID.SetWindowText(NewID);
	time=time.GetCurrentTime();
	cTime=CTimeToCString(time); 
	this->m_StaDate.SetWindowText(cTime);
	this->clear();	
}

BOOL CDSell::OnInitDialog() 
{
	CDialog::OnInitDialog();
	bool isInit;
	
	rst.Open("SELECT * from 客户信息表",adCmdText);
	isInit=this->m_EdtCliect.Initialize(this);
	this->m_EdtCliect.StartUpAssciation=true;
	this->m_EdtCliect.SetRecordset(rst);
	this->m_EdtCliect.SetSelectField("名称");

	rst.Open("SELECT * from 员工信息表",adCmdText);
	isInit=this->m_EdtDealMan.Initialize(this);
	this->m_EdtDealMan.StartUpAssciation=true;
	this->m_EdtDealMan.SetRecordset(rst);
	this->m_EdtDealMan.SetSelectField("名称");
	
	CString Fields[]={"商品名称","规格","产地","计量单位","销售数量","单价","合计"};
	int ColWidth[]={140,70,140,70,70,70,70};
	for(int m=0;m<7;m++)
	{
		m_Grid.InsertColumn(m,Fields[m]);
		m_Grid.SetColumnWidth(m,ColWidth[m]);
	}	
	m_Grid.m_Edit.Initialize(this);

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



void CDSell::Enabled(bool bEnabled)
{
	m_EdtCliect.EnableWindow(bEnabled);
	m_EdtDealMan.EnableWindow(bEnabled);
	m_ButCleck.EnableWindow(!bEnabled);	
	m_ButSave.EnableWindow(bEnabled);	
	m_ButUndo.EnableWindow(bEnabled);
	m_ButExit.EnableWindow(!bEnabled);
	m_ComStyle.EnableWindow(bEnabled);
	m_EdtPay.EnableWindow(bEnabled);
	this->m_EdtPay.EnableWindow(bEnabled);
	this->m_ComRID.EnableWindow(bEnabled);


}

void CDSell::OnKillfocusComrid() 
{
	CString sText,sName,sID,sSQL;
	this->m_ComRID.GetWindowText(sText);
	sSQL.Format("SELECT * FROM 订货明细表 WHERE 票号='%s'",sText);	
	m_Grid.ReadOnly(true);
	rst.Open(sSQL,adCmdText);
	m_Grid.DeleteAllItems();
	for(int i=0;i<rst.GetRecordCount();i++)
	{
		m_Grid.InsertItem(i,"");
	}
	float fMoney,fSumMoney=0.00;	
	int nSumNumber=0;
	CString sMoney,sSumMoney,sSumNumber;
	for(i=0;i<rst.GetRecordCount();i++)
	{
		rst.Move(i);
		sID=rst.GetFieldValue("商品编号");
		sName=ado.FieldToOtherField("商品信息表","编号",sID,"名称",1);
		this->m_Grid.SetItemText(i,0,sName);
		this->m_Grid.SetItemText(i,1,ado.FieldToOtherField("商品信息表","编号",sID,"规格",1));
		this->m_Grid.SetItemText(i,2,ado.FieldToOtherField("商品信息表","编号",sID,"产地",1));
		this->m_Grid.SetItemText(i,3,ado.FieldToOtherField("商品信息表","编号",sID,"计量单位",1));
		this->m_Grid.SetItemText(i,4,rst.GetFieldValue("数量"));
		this->m_Grid.SetItemText(i,5,rst.GetFieldValue("单价"));
		fMoney=(atof(rst.GetFieldValue("数量"))*atof(rst.GetFieldValue("单价")));
		sMoney.Format("%f",fMoney);
		this->m_Grid.SetItemText(i,6,sMoney);
		fSumMoney=fSumMoney+atof(sMoney);
		nSumNumber=nSumNumber+atoi(rst.GetFieldValue("数量"));
	}
	sSumMoney.Format("%f",fSumMoney);
	sSumNumber.Format("%d",nSumNumber);
	this->m_StaSmallSum.SetWindowText(sSumMoney);
	this->m_StaSumNumber.SetWindowText(sSumNumber);
	this->m_StaBigSum.SetWindowText(MoneyToChineseCode(sSumMoney));
	this->m_EdtPay.SetFocus();
}

void CDSell::OnBUTPrint() 
{
	CString sName,sDate,sCliect,sSumMoney,sBigMoney,sSumNumber,sID;
	RxRecordset brst;
	brst.Open("系统设置表");
	sName=brst.GetFieldValue("公司名称");
	sName=sName+"销售发票";
	this->m_StaDate.GetWindowText(sDate);
	this->m_EdtCliect.GetWindowText(sCliect);
	this->m_StaSmallSum.GetWindowText(sSumMoney);
	this->m_StaBigSum.GetWindowText(sBigMoney);
	this->m_StaSumNumber.GetWindowText(sSumNumber);
	this->m_StaID.GetWindowText(sID);
	m_ps.MainCaptionFontSize=400;
	m_ps.DeckCaptionFontSize=180;
	m_ps.DeckCaptionNumber=3;
	m_ps.DeckCaptions[0]="销售编号:"+sID;
	m_ps.DeckCaptions[1]="销售日期:"+sDate;
	m_ps.DeckCaptions[2]="客户:"+sCliect;
	m_ps.MainCaption=sName;
	m_ps.Grid=&m_Grid;
	m_ps.TotalNumber=3;
	m_ps.Totals[0]="合计金额(小写):"+sSumMoney;
	m_ps.Totals[1]="合计数量:"+sSumNumber; 
	m_ps.Totals[2]="合计金额(大写):"+sBigMoney;
	theApp.Print();	
}

void CDSell::OnBUTSave() 
{
	if(MessageBox("确定要保存此销售单吗?","系统提示",MB_OKCANCEL|MB_ICONQUESTION)!=1)
		return;	
	CString sSQL,sPay,sNotPay,sGiveChange,sWare,sWareID,sStoreNUM,sSpec,sPrice,sNumber,sAddr,sCID,sDate,sCliectName,sCliectID,sDeal,sStyle,sRID,sSumMoney,sSumNumber,OPID;
	this->m_StaID.GetWindowText(sCID);
	sCID.TrimLeft();
	sCID.TrimRight();
	this->m_EdtPay.GetWindowText(sPay);
	if(sPay.IsEmpty())
	{
		MessageBox("此客户还没有结款!","系统提示",MB_OK|MB_ICONSTOP);
		this->m_EdtPay.SetFocus();
		return;
	}
	this->m_StaNotPay.GetWindowText(sNotPay);
	this->m_StaGiveChange.GetWindowText(sGiveChange);
	this->m_StaDate.GetWindowText(sDate);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -