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

📄 invoicedlg.cpp

📁 一个企业订单管理流程的例子
💻 CPP
📖 第 1 页 / 共 3 页
字号:
// InvoiceDlg.cpp : implementation file

#include "stdafx.h"
#include "Invoice.h"
#include "InvoiceDlg.h"
#include "Mdb.h"
#include "MdbDlg.h"
#include "io.h"
#include "PrintSetup.h"
#include "OlddatDlg.h"
#include "MdbSaveDat.h"
#include "PswDlg.h"

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

#define SAVE_MDBDATA_MAXNO 50000
#define REPORT_DAT_MAXNO 200
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
CString ttt0[SAVE_MDBDATA_MAXNO],ttt1[SAVE_MDBDATA_MAXNO],ttt2[SAVE_MDBDATA_MAXNO];
int m_ttt_maxno;

//////////
//////////////报表数据
struct REPORT_DATA{
	CString order_form; 
	CString goods_num;
  	CString goods_mode;
  	double   goods_unitprice;
	long    goods_maxno;
	double   goods_maxprice;
	CString remark;
}report_data[REPORT_DAT_MAXNO];
long report_data_maxno=0;

//////////

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()

/////////////////////////////////////////////////////////////////////////////
// CInvoiceDlg dialog

CInvoiceDlg::CInvoiceDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CInvoiceDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CInvoiceDlg)
	m_out_goodsmode = _T("");
 	m_out_goodsno =  _T("");
	m_out_goodsnum = _T("");
	m_out_orderform = _T("");
	m_out_remark = _T("");
	m_out_client = _T("");
	m_out_createtableman = _T("");
	m_out_goodsprice = _T("");
	m_out_goodsunitprice = _T("");
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CInvoiceDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CInvoiceDlg)
	DDX_Control(pDX, IDC_LIST_MDBOUT, m_list_mdbout);
	DDX_Control(pDX, IDC_LIST_ZTOUT, m_list_resultout);
	DDX_Text(pDX, IDC_OUT_GOODS_MODE, m_out_goodsmode);
	DDX_Text(pDX, IDC_OUT_GOODS_NO, m_out_goodsno);
	DDX_Text(pDX, IDC_OUT_GOODS_NUM, m_out_goodsnum);
	DDX_Text(pDX, IDC_OUT_ORDER_FORM, m_out_orderform);
	DDX_Text(pDX, IDC_OUT_REMARK, m_out_remark);
	DDX_Text(pDX, IDC_OUT_CLIENT, m_out_client);
	DDX_Text(pDX, IDC_OUT_CREATTABLEMAN, m_out_createtableman);
	DDX_Text(pDX, IDC_OUT_GOODS_PRICE, m_out_goodsprice);
	DDX_Text(pDX, IDC_OUT_UNIT_PRICE, m_out_goodsunitprice);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CInvoiceDlg, CDialog)
	//{{AFX_MSG_MAP(CInvoiceDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_BN_CLICKED(IDC_BUTTON_QUERY, OnQuery)
	ON_BN_CLICKED(IDC_BUTTON_CLEARLIST, OnClearlist)
	ON_BN_CLICKED(IDC_BUTTON_OUT_INSERT, OnOutInsert)
	ON_BN_CLICKED(IDC_BUTTON_OUT_DELETE, OnOutDelete)
	ON_BN_CLICKED(IDC_BUTTON_OUT_REVIEW, OnPrint)
	ON_BN_CLICKED(IDC_BUTTON_OUT_CHANGE, OnOutChange)
	ON_BN_CLICKED(IDC_BUTTON_DOMDB, OnDoMdb)
	ON_NOTIFY(NM_CLICK, IDC_LIST_ZTOUT, OnClickListResultout)
	ON_BN_CLICKED(IDC_BUTTON_OLDDAT, OnDoOlddat)
	ON_BN_CLICKED(IDC_BUTTON_SAVEMDB, OnSaveTradeDat)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CInvoiceDlg message handlers

BOOL CInvoiceDlg::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_list_resultout.SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES);
	m_list_resultout.InsertColumn(0,"序号",LVCFMT_LEFT,60,50);
	m_list_resultout.InsertColumn(1,"   订单号",LVCFMT_LEFT,100,50);	
	m_list_resultout.InsertColumn(2,"   货品编号",LVCFMT_LEFT,100,50);
	m_list_resultout.InsertColumn(3," 电   镀",LVCFMT_LEFT,80,50);
	m_list_resultout.InsertColumn(4,"单价(元)",LVCFMT_LEFT,80,50);
	m_list_resultout.InsertColumn(5,"   数量(件)",LVCFMT_LEFT,100,50);
	m_list_resultout.InsertColumn(6,"   金    额",LVCFMT_LEFT,100,50);
	m_list_resultout.InsertColumn(7,"             备      注 ",LVCFMT_LEFT,270,50);

	/////////////初始化输出状态表
	m_list_mdbout.SetExtendedStyle(LVS_EX_GRIDLINES);
	m_list_mdbout.InsertColumn(0,"   序  号",LVCFMT_LEFT,80,50);
	m_list_mdbout.InsertColumn(1,"       货 品 编 号",LVCFMT_LEFT,170,50);
	m_list_mdbout.InsertColumn(2,"     电   镀",LVCFMT_LEFT,120,50);
	m_list_mdbout.InsertColumn(3,"     单价(元)",LVCFMT_LEFT,120,50);

	//////////
	m_query_xh=0;

	

	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CInvoiceDlg::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 CInvoiceDlg::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 CInvoiceDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}

void CInvoiceDlg::OnQuery() 
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);

	if(m_out_goodsunitprice.IsEmpty()!=1)
	{
		if(CheckDat(m_out_goodsunitprice,1)==0)
		{
			AfxMessageBox("单价输入错误");
			return;
		}
	}

	if(m_out_goodsnum.IsEmpty()==1
		&&m_out_goodsmode.IsEmpty()==1
		&&m_out_goodsunitprice.IsEmpty()==1)
	{
		AfxMessageBox("查询时 至少有一项不能为空");
		return;
	}
	

   	ttt0[0]=m_out_goodsnum;
	ttt1[0]=m_out_goodsmode;
	ttt2[0]=m_out_goodsunitprice;
	m_ttt_maxno=Mdb.QueryMdbDao(ttt0,ttt1,ttt2);
	if(m_ttt_maxno==0)
	{
		AfxMessageBox("没有查询到记录!");
		return;
	}

	m_out_goodsnum =ttt0[0];
	m_out_goodsmode =ttt1[0];
    m_out_goodsunitprice = ttt2[0];//atof(ttt2[0]);//Double.valueof(ttt2[0]).doubleValue();
	

	UpdateData(FALSE);

	OutMdbQueryscr();
	
	return;
}

int CInvoiceDlg::OutScr()
{	
	char str[256];
	int no;

	for(no=0;no<Mdb.mdb_goods_maxno;no++,m_query_xh++)
	{
		sprintf(str,"%05d",m_query_xh);
		m_list_resultout.InsertItem(m_query_xh,str);

		sprintf(str,"%s",Mdb.mdb_goods[no].t_goods_num);
		m_list_resultout.SetItemText(m_query_xh,2,str);

		sprintf(str,"%s",Mdb.mdb_goods[no].t_goods_mode);
		m_list_resultout.SetItemText(m_query_xh,3,str);

		sprintf(str,"%s",Mdb.mdb_goods[no].t_goods_unitprice);
		m_list_resultout.SetItemText(m_query_xh,4,str);
	}
	
	return 1;
}


int CInvoiceDlg::ClearList()
{
	int list_no;
	int i;

	list_no=m_list_resultout.GetItemCount();
	for(i=list_no;i>=0;i--)
	{
		m_list_resultout.DeleteItem(i);
	}
	
	return 0;
}

void CInvoiceDlg::OnClearlist() 
{
	// TODO: Add your control notification handler code here
	if(MBox("清除输出表所有")==0)
	{
		return;
	}

	report_data_maxno=0;
	m_query_xh=0;
	m_ttt_maxno=0;

	m_out_goodsmode = _T("");
 	m_out_goodsno =  _T("");
	m_out_goodsnum = _T("");
 	m_out_goodsprice =  _T("");
	m_out_orderform = _T("");
	m_out_remark = _T("");
 	m_out_goodsunitprice = _T("");
	m_out_client = _T("");
	m_out_createtableman = _T("");

	UpdateData(FALSE);

	ClearList();
}

void CInvoiceDlg::OnOutInsert() 
{
	// TODO: Add your control notification handler code here
	if(MBox("添加此条")==0)
	{
		return;
	}
	UpdateData(TRUE);

	if(m_out_goodsunitprice.IsEmpty()!=1)
	{
		if(CheckDat(m_out_goodsunitprice,1)==0)
		{
			AfxMessageBox("单价输入错误");
			return;
		}
	}
	if(m_out_goodsno.IsEmpty()!=1)
	{
		if(CheckDat(m_out_goodsno,0)==0)
		{
			AfxMessageBox("数量输入错误");
			return;
		}
	}
	
	if(m_out_orderform.IsEmpty()==1)
	{
		AfxMessageBox("插入时 订单号项不能为空");
		return;
	}
	if(m_out_goodsnum.IsEmpty()==1)
	{
		AfxMessageBox("插入时 货品编号项不能为空");
		return;
	}
	if(m_out_goodsmode.IsEmpty()==1)
	{
		AfxMessageBox("插入时 电镀项不能为空");
		return;
	}	
	if(m_out_goodsunitprice.IsEmpty()==1)
	{
		AfxMessageBox("插入时 单价项不能为空");
		return;
	}
	if(m_out_goodsno.IsEmpty()==1)
	{
		AfxMessageBox("插入时 数量项不能为空");
		return;
	}

	if(QchOutTable()==0)
	{
		AfxMessageBox("表中已存在此项");
		return;		
	}

	//////////////报表数据
	report_data[report_data_maxno].order_form=m_out_orderform;
	report_data[report_data_maxno].goods_num =m_out_goodsnum;
	report_data[report_data_maxno].goods_mode =m_out_goodsmode;
    report_data[report_data_maxno].goods_unitprice= atof(m_out_goodsunitprice);
    report_data[report_data_maxno].goods_maxno=atol(m_out_goodsno);
	report_data[report_data_maxno].goods_maxprice=report_data[report_data_maxno].goods_maxno* report_data[report_data_maxno].goods_unitprice;
	report_data[report_data_maxno].remark=m_out_remark ;

	//m_out_goodsprice=strtod(report_data[report_data_maxno].goods_maxprice,);

	m_out_goodsprice.Format("%2.2f",report_data[report_data_maxno].goods_maxprice);

	UpdateData(FALSE);

	OutTableSrc();

	report_data_maxno++;
}

int CInvoiceDlg::OutTableSrc()
{
	char str[256];

	sprintf(str,"%05d",m_query_xh);
	m_list_resultout.InsertItem(m_query_xh,str);

⌨️ 快捷键说明

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