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

📄 olddatdlg.cpp

📁 一个企业订单管理流程的例子
💻 CPP
字号:
// OlddatDlg.cpp : implementation file
//

#include "stdafx.h"
#include "Invoice.h"
#include "OlddatDlg.h"
#include "MdbSaveDat.h"
#include "ProtcolOutDlg.h"
#include "PswDlg.h"

#define TRADE_MAXNO 50000

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


/////////////////////////////////////////////////////////////////////////////
// COlddatDlg dialog
CString t_tradetime[TRADE_MAXNO];
CString trade_protcol[TRADE_MAXNO];
CString trade_client[TRADE_MAXNO];
CString trade_maxno[TRADE_MAXNO];
CString trade_maxprice[TRADE_MAXNO];
int trade_no=0;

COlddatDlg::COlddatDlg(CWnd* pParent /*=NULL*/)
	: CDialog(COlddatDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(COlddatDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void COlddatDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(COlddatDlg)
	DDX_Control(pDX, IDC_LIST_TRADE, m_list_trade);
	DDX_Control(pDX, IDC_DIRECTORY_TREE, m_DirTree);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(COlddatDlg, CDialog)
	//{{AFX_MSG_MAP(COlddatDlg)
	ON_NOTIFY(NM_DBLCLK, IDC_LIST_TRADE, OnDblclkListTrade)
	ON_BN_CLICKED(IDC_BUTTON_DELETEP_PROTCOL, OnDeletepProtcol)
	ON_NOTIFY(NM_CLICK, IDC_LIST_TRADE, OnClickListTrade)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
BOOL COlddatDlg::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

	CreatTree();

	m_list_trade.SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES);
	m_list_trade.InsertColumn(0," 序号",LVCFMT_LEFT,60,50);
	m_list_trade.InsertColumn(1," 时间",LVCFMT_LEFT,60,50);	
	m_list_trade.InsertColumn(2,"  合       同",LVCFMT_LEFT,110,50);
	m_list_trade.InsertColumn(3,"  客       户",LVCFMT_LEFT,110,50);
	m_list_trade.InsertColumn(4,"  交易数量(件)",LVCFMT_LEFT,110,50);
	m_list_trade.InsertColumn(5,"  交易金额(元)",LVCFMT_LEFT,110,50);

	m_select_protcol="";

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

int COlddatDlg::OutTradeProtcol(char *m_time)
{
	CMdbSaveDat MdbSaveDat;	
	char str[256];
	int  no;
	
	trade_no=MdbSaveDat.QueryMdbSave1(m_time,t_tradetime,
		trade_protcol,
		trade_client,
		trade_maxno,
		trade_maxprice);

	m_list_trade.DeleteAllItems();
	for(no=0;no<trade_no;no++)
	{
		sprintf(str,"%05d",no);
		m_list_trade.InsertItem(no,str);

		sprintf(str,"%s",t_tradetime[no]);
		m_list_trade.SetItemText(no,1,str);

		sprintf(str,"%s",trade_protcol[no]);
		m_list_trade.SetItemText(no,2,str);

		sprintf(str,"%s",trade_client[no]);
		m_list_trade.SetItemText(no,3,str);

		sprintf(str,"%s",trade_maxno[no]);
		m_list_trade.SetItemText(no,4,str);

		sprintf(str,"%s",trade_maxprice[no]);
		m_list_trade.SetItemText(no,5,str);
	}
	
	return 0;
}

void COlddatDlg::OnOK() 
{
	// TODO: Add extra validation here

 	CDialog::OnOK();
}

void COlddatDlg::CreatTree()
{
		CImageList * pImageList;
	//CImageList  pImageList;
	pImageList = new CImageList();
	pImageList->Create(16, 16, ILC_COLOR, 4, 4);
	//pImageList.Create(16, 16, ILC_COLOR, 4, 4);

	// 导入位图,必须在CDirectoryTree对象初始化之前进行
	CBitmap	bBitmap;
	for (int nID = IDB_FIRST_TREE_ICON; nID < IDB_LAST_TREE_ICON; nID++)
	{
		bBitmap.LoadMappedBitmap(nID);
		pImageList->Add(&bBitmap, (COLORREF)0x000000);
		bBitmap.DeleteObject();
	}
	m_DirTree.SetBitmapList(pImageList);

	// 初始化
	m_DirTree.Initialize();
}

void COlddatDlg::OnDblclkListTrade(NMHDR* pNMHDR, LRESULT* pResult) 
{
	// TODO: Add your control notification handler code here
	CProtcolOutDlg ProtcolOutDlg;

	POSITION  pos=m_list_trade.GetFirstSelectedItemPosition();

	m_select_protcol=m_list_trade.GetItemText(int(pos-1),2);
	if(m_select_protcol!="")
	{
		ProtcolOutDlg.m_select_protcol=m_select_protcol;
		ProtcolOutDlg.DoModal();
	}
	//	ProtcolOutDlg.SetWindowText("ffff");
	
	*pResult = 0;
}

void COlddatDlg::OnDeletepProtcol() 
{
	// TODO: Add your control notification handler code here
	CMdbSaveDat MdbSaveDat;	
	char str[256];
	int  no;
	CString sline;
//	CPswDlg PswDlg;

	if(m_user!="LKJ_RK1")
	{
		AfxMessageBox("对不起,你没有删除权限!");
		return ;
	}

	if(m_select_protcol=="")
	{
		AfxMessageBox("请选定要删除的合同");
		return;
	}

	sline.Format("确定要删除合同%s吗?",m_select_protcol);
	if(MessageBox(sline,"删除记录",MB_YESNO|MB_ICONINFORMATION)!=IDYES)
		return ;


	//////////////////列表删除
	trade_no--;
	for(no=m_list_trade_no;no<trade_no;no++)
	{
		t_tradetime[no]=t_tradetime[no+1];
		trade_protcol[no]=trade_protcol[no+1];
		trade_client[no]=trade_client[no+1];
		trade_maxno[no]=trade_maxno[no+1];
		trade_maxprice[no]=trade_maxprice[no+1];
	}	
	for(no=m_list_trade_no;no<trade_no;no++)
	{
		m_list_trade.DeleteItem(no);
		
		sprintf(str,"%05d",no);
		m_list_trade.InsertItem(no,str);

		sprintf(str,"%s",t_tradetime[no]);
		m_list_trade.SetItemText(no,1,str);

		sprintf(str,"%s",trade_protcol[no]);
		m_list_trade.SetItemText(no,2,str);

		sprintf(str,"%s",trade_client[no]);
		m_list_trade.SetItemText(no,3,str);

		sprintf(str,"%s",trade_maxno[no]);
		m_list_trade.SetItemText(no,4,str);

		sprintf(str,"%s",trade_maxprice[no]);
		m_list_trade.SetItemText(no,5,str);
	}
	m_list_trade.DeleteItem(trade_no);	


	/////数据库删除
	MdbSaveDat.DeleteMdbDao(m_select_protcol);

	m_select_protcol="";

	CreatTree();
}

void COlddatDlg::OnClickListTrade(NMHDR* pNMHDR, LRESULT* pResult) 
{
	// TODO: Add your control notification handler code here
	POSITION  pos=m_list_trade.GetFirstSelectedItemPosition();

	m_list_trade_no=(int)(pos-1);
	m_select_protcol=m_list_trade.GetItemText(int(pos-1),2);
	
	*pResult = 0;
}

⌨️ 快捷键说明

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