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

📄 dlgsell.cpp

📁 商品销售
💻 CPP
字号:
// DlgSell.cpp : implementation file
//

#include "stdafx.h"
#include "merchandisesell.h"
#include "DlgSell.h"
#include "Database.h"

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

//-------------global 
extern CDatabase m_hDatabase ;
//------------end

/////////////////////////////////////////////////////////////////////////////
// CDlgSell dialog


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


void CDlgSell::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDlgSell)
	DDX_Control(pDX, IDC_BTN_FIND, m_hBtnFind);
	DDX_Control(pDX, IDOK, m_hBtnOk);
	DDX_Control(pDX, IDC_TAB_CANCELSELL, m_hTabCancelSell);
	DDX_Control(pDX, IDC_LIST_CANCELSELL, m_hListCancelSell);
	DDX_Control(pDX, IDC_EDIT_UNITPRICE, m_hEditUnitPrice);
	DDX_Control(pDX, IDC_EDIT_SUMTOTAL, m_hEditSumTotal);
	DDX_Control(pDX, IDC_EDIT_STOCKNAME, m_hEditStockName);
	DDX_Control(pDX, IDC_EDIT_REBATE, m_hEditRebate);
	DDX_Control(pDX, IDC_EDIT_PAYMONEY, m_hEditPayMoney);
	DDX_Control(pDX, IDC_EDIT_OPERATOR, m_hEditOperator);
	DDX_Control(pDX, IDC_EDIT_NUMBERS, m_hEditNumbers);
	DDX_Control(pDX, IDC_EDIT_MERCHANDISEID, m_hEditMerchandiseID);
	DDX_Control(pDX, IDC_EDIT_FACTMONEY, m_hEditFactMoney);
	DDX_Control(pDX, IDC_EDIT_CUSTOMER, m_hEditCustomer);
	DDX_Control(pDX, IDC_EDIT_CANCELID, m_hEditCancelID);
	DDX_Control(pDX, IDC_DATETIMEPICKER2, m_hDtpTime);
	DDX_Control(pDX, IDC_DATETIMEPICKER1, m_hDtpDate);
	DDX_Control(pDX, IDC_BTN_SAVE, m_hBtnSave);
	DDX_Control(pDX, IDC_BTN_MOD, m_hBtnMod);
	DDX_Control(pDX, IDC_BTN_DEL, m_hBtnDel);
	DDX_Control(pDX, IDC_BTN_ADD, m_hBtnAdd);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDlgSell, CDialog)
	//{{AFX_MSG_MAP(CDlgSell)
	ON_NOTIFY(TCN_SELCHANGE, IDC_TAB_CANCELSELL, OnSelchangeTabCancelsell)
	ON_NOTIFY(NM_CLICK, IDC_LIST_CANCELSELL, OnClickListCancelsell)
	ON_NOTIFY(NM_DBLCLK, IDC_LIST_CANCELSELL, OnDblclkListCancelsell)
	ON_BN_CLICKED(IDC_BTN_ADD, OnBtnAdd)
	ON_BN_CLICKED(IDC_BTN_DEL, OnBtnDel)
	ON_BN_CLICKED(IDC_BTN_MOD, OnBtnMod)
	ON_BN_CLICKED(IDC_BTN_SAVE, OnBtnSave)
	ON_BN_CLICKED(IDC_BTN_FIND, OnBtnFind)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDlgSell message handlers

void CDlgSell::OnSelchangeTabCancelsell(NMHDR* pNMHDR, LRESULT* pResult) 
{
	// TODO: Add your control notification handler code here
	switch(m_hTabCancelSell.GetCurSel())
	{
	case 0:
		TabCtrlOfSelect(0) ;
		break ;
	case 1:
		TabCtrlOfSelect(1) ;
		break ;
	}	
	
	*pResult = 0;
}

void CDlgSell::OnClickListCancelsell(NMHDR* pNMHDR, LRESULT* pResult) 
{
	// TODO: Add your control notification handler code here
	char CancelID[30+1] ;
	m_hListCancelSell.GetItemText(m_hListCancelSell.GetSelectionMark(), 0, CancelID, sizeof(CancelID)) ;

	m_hDatabase.EditSellToCtrl(CancelID, &m_hEditCancelID, &m_hEditUnitPrice, &m_hEditSumTotal, &m_hEditStockName, &m_hEditRebate, &m_hEditPayMoney, &m_hEditOperator, &m_hEditNumbers, &m_hEditMerchandiseID, &m_hEditFactMoney, &m_hEditCustomer) ;
	
	*pResult = 0;
}

void CDlgSell::OnDblclkListCancelsell(NMHDR* pNMHDR, LRESULT* pResult) 
{
	// TODO: Add your control notification handler code here
	TabCtrlOfSelect(0) ;
	
	*pResult = 0;
}

void CDlgSell::OnBtnAdd() 
{
	// TODO: Add your control notification handler code here
	switch(m_hTabCancelSell.GetCurSel())
	{
	case 0:
		{
			break ;
		}
	case 1:
		{
			TabCtrlOfSelect(0) ;
			break ;
		}
	}

	m_hEditUnitPrice.SetWindowText("") ;
	m_hEditSumTotal.SetWindowText("") ;
	m_hEditStockName.SetWindowText("") ;
	m_hEditRebate.SetWindowText("") ;
	m_hEditPayMoney.SetWindowText("") ;
	m_hEditOperator.SetWindowText("") ;
	m_hEditMerchandiseID.SetWindowText("") ;
	m_hEditFactMoney.SetWindowText("") ;
	m_hEditCustomer.SetWindowText("") ;
	m_hEditCancelID.SetWindowText("") ;
	m_hEditNumbers.SetWindowText("") ;
	m_hEditCancelID.SetFocus() ;
	m_hBtnSave.EnableWindow() ;		
	
}

void CDlgSell::OnBtnDel() 
{
	// TODO: Add your control notification handler code here
	if(m_hListCancelSell.GetSelectionMark() == -1)
	{//未被选中
		MessageBox("请选择欲删除条目!") ;
		return ;
	}
	char m_szCancelID[30+1] ;
	m_hListCancelSell.GetItemText(m_hListCancelSell.GetSelectionMark(), 0, m_szCancelID, sizeof(m_szCancelID)) ;
	m_hDatabase.DeleteDataWhere(SPXS, m_szCancelID) ;
	TabCtrlOfSelect(1) ;	
	
}

void CDlgSell::OnBtnMod() 
{
	// TODO: Add your control notification handler code here
	switch(m_hTabCancelSell.GetCurSel())
	{
	case 0:
		{
			break ;
		}
	case 1:
		{
			if(m_hListCancelSell.GetSelectionMark() == -1)
			{//未被选中
				MessageBox("请选择欲修改条目!") ;
				return ;
			}
			break ;
		}
	}
	TabCtrlOfSelect(0) ;
	m_hBtnSave.EnableWindow() ;
	m_hEditCancelID.SetFocus() ;	
	
}

void CDlgSell::OnBtnSave() 
{
	// TODO: Add your control notification handler code here
	char CancelID[30+1], Customer[30+1], ooperator[50+1], rebate[10+1], sumtotal[10+1], paymoney[10+1], factmoney[10+1], intime[20+1]="", merchandiseID[30+1], unitPrice[10+1], numbers[10+1], stockname[30+1] ;

	m_hEditCancelID.GetWindowText(CancelID, sizeof(CancelID)) ;
	m_hEditCustomer.GetWindowText(Customer, sizeof(Customer)) ;
	m_hEditOperator.GetWindowText(ooperator, sizeof(ooperator)) ;
	m_hEditRebate.GetWindowText(rebate, sizeof(rebate)) ;
	m_hEditSumTotal.GetWindowText(sumtotal, sizeof(sumtotal)) ;
	m_hEditPayMoney.GetWindowText(paymoney, sizeof(paymoney)) ;
	m_hEditFactMoney.GetWindowText(factmoney, sizeof(factmoney)) ;
	m_hEditMerchandiseID.GetWindowText(merchandiseID, sizeof(merchandiseID)) ;
	m_hEditUnitPrice.GetWindowText(unitPrice, sizeof(unitPrice)) ;
	m_hEditNumbers.GetWindowText(numbers, sizeof(numbers)) ;
	m_hEditStockName.GetWindowText(stockname, sizeof(stockname)) ;

	//保存修改,更新数据库
	m_hDatabase.UpdateSellData(CancelID,Customer,ooperator,rebate,sumtotal,paymoney,factmoney,intime,merchandiseID,unitPrice,numbers,stockname) ;

	m_hBtnSave.EnableWindow(FALSE) ;	
	
}

void CDlgSell::OnBtnFind() 
{
	// TODO: Add your control notification handler code here
	
}

void CDlgSell::TabCtrlOfSelect(int m_nSelected)
{
	switch(m_nSelected)
	{
	case 0:
		{
			m_hTabCancelSell.SetCurSel(0) ;
			//---
			m_hEditUnitPrice.ShowWindow(TRUE) ;
			m_hEditSumTotal.ShowWindow(TRUE) ;
			m_hEditStockName.ShowWindow(TRUE) ;
			m_hEditRebate.ShowWindow(TRUE) ;
			m_hEditPayMoney.ShowWindow(TRUE) ;
			m_hEditOperator.ShowWindow(TRUE) ;
			m_hEditNumbers.ShowWindow(TRUE) ;
			m_hEditMerchandiseID.ShowWindow(TRUE) ;
			m_hEditFactMoney.ShowWindow(TRUE) ;
			m_hEditCustomer.ShowWindow(TRUE) ;
			m_hEditCancelID.ShowWindow(TRUE) ;
			m_hDtpDate.ShowWindow(TRUE) ;
			m_hDtpTime.ShowWindow(TRUE) ;
			
			m_hListCancelSell.ShowWindow(FALSE) ;
			m_hEditCancelID.SetFocus() ;
			break ;
		}
	case 1:
		{
			m_hTabCancelSell.SetCurSel(1) ;
			//---
			m_hEditUnitPrice.ShowWindow(FALSE) ;
			m_hEditSumTotal.ShowWindow(FALSE) ;
			m_hEditStockName.ShowWindow(FALSE) ;
			m_hEditRebate.ShowWindow(FALSE) ;
			m_hEditPayMoney.ShowWindow(FALSE) ;
			m_hEditOperator.ShowWindow(FALSE) ;
			m_hEditNumbers.ShowWindow(FALSE) ;
			m_hEditMerchandiseID.ShowWindow(FALSE) ;
			m_hEditFactMoney.ShowWindow(FALSE) ;
			m_hEditCustomer.ShowWindow(FALSE) ;
			m_hEditCancelID.ShowWindow(FALSE) ;
			m_hDtpDate.ShowWindow(FALSE) ;
			m_hDtpTime.ShowWindow(FALSE) ;
			
			m_hListCancelSell.ShowWindow(TRUE) ;
			break ;
		}
	}
	m_hDatabase.ListSellToCtrl(&m_hListCancelSell) ;

}

void CDlgSell::InitCtrlData()
{
	m_hTabCancelSell.InsertItem(0, "商品销售基本信息") ;
	m_hTabCancelSell.InsertItem(1, "商品销售信息列表") ;
	m_hTabCancelSell.ShowWindow(TRUE) ;

//
	m_hListCancelSell.InsertColumn(0, "销售单号", LVCFMT_CENTER, 80) ;
	m_hListCancelSell.InsertColumn(1, "客户", LVCFMT_CENTER, 50) ;
	m_hListCancelSell.InsertColumn(2, "操作员", LVCFMT_CENTER, 80) ;
	m_hListCancelSell.InsertColumn(3, "折扣", LVCFMT_CENTER, 50) ;
	m_hListCancelSell.InsertColumn(4, "总计", LVCFMT_CENTER, 50) ;
	m_hListCancelSell.InsertColumn(5, "应付金额", LVCFMT_CENTER, 80) ;
	m_hListCancelSell.InsertColumn(6, "实付金额", LVCFMT_CENTER, 80) ;
	m_hListCancelSell.InsertColumn(7, "仓库名称", LVCFMT_CENTER, 80) ;
	m_hListCancelSell.InsertColumn(8, "商品编号", LVCFMT_CENTER, 80) ;
	m_hListCancelSell.InsertColumn(9, "单价", LVCFMT_CENTER, 50) ;
	m_hListCancelSell.InsertColumn(10, "数量", LVCFMT_CENTER, 50) ;
	m_hListCancelSell.InsertColumn(11, "金额", LVCFMT_CENTER, 50) ;
	m_hListCancelSell.InsertColumn(12, "时间", LVCFMT_CENTER, 80) ;
	m_hListCancelSell.SetExtendedStyle(m_hListCancelSell.GetStyle() | LVS_EX_FULLROWSELECT);
	
///INIT BUTTON CTRL
	m_hBtnOk.SetIcon(IDI_ICON_CLOSE);
	m_hBtnOk.OffsetColor(CButtonST::BTNST_COLOR_BK_IN, shBtnColor);
	m_hBtnOk.SetColor(CButtonST::BTNST_COLOR_FG_IN, RGB(0, 128, 0));

	m_hBtnSave.SetIcon(IDI_ICON_OK);
	m_hBtnSave.OffsetColor(CButtonST::BTNST_COLOR_BK_IN, shBtnColor);
	m_hBtnSave.SetColor(CButtonST::BTNST_COLOR_FG_IN, RGB(0, 128, 0));
	m_hBtnSave.EnableWindow(FALSE) ;

	m_hBtnDel.SetIcon(IDI_ICON_DEL);
	m_hBtnDel.OffsetColor(CButtonST::BTNST_COLOR_BK_IN, shBtnColor);
	m_hBtnDel.SetColor(CButtonST::BTNST_COLOR_FG_IN, RGB(0, 128, 0));

	m_hBtnAdd.SetIcon(IDI_ICON_ADD);
	m_hBtnAdd.OffsetColor(CButtonST::BTNST_COLOR_BK_IN, shBtnColor);
	m_hBtnAdd.SetColor(CButtonST::BTNST_COLOR_FG_IN, RGB(0, 128, 0));

	m_hBtnMod.SetIcon(IDI_ICON_MOD);
	m_hBtnMod.OffsetColor(CButtonST::BTNST_COLOR_BK_IN, shBtnColor);
	m_hBtnMod.SetColor(CButtonST::BTNST_COLOR_FG_IN, RGB(0, 128, 0));

	m_hBtnFind.SetIcon(IDI_ICON_FIND);
	m_hBtnFind.OffsetColor(CButtonST::BTNST_COLOR_BK_IN, shBtnColor);
	m_hBtnFind.SetColor(CButtonST::BTNST_COLOR_FG_IN, RGB(0, 128, 0));
//----------
	TabCtrlOfSelect(1) ;

}

BOOL CDlgSell::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here

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

⌨️ 快捷键说明

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