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

📄 sseodinfodlg.cpp

📁 订单管理系统
💻 CPP
字号:
// SSeOdInfoDlg.cpp : implementation file
//

#include "stdafx.h"
#include "ordermanagement.h"
#include "SSeOdInfoDlg.h"
#include "ADOConn.h"
#include "SeOdInfoDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// SSeOdInfoDlg dialog


SSeOdInfoDlg::SSeOdInfoDlg(CWnd* pParent /*=NULL*/)
	: CDialog(SSeOdInfoDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(SSeOdInfoDlg)
	m_kstr = _T("");
	m_nSearch = -1;
	m_nSort = -1;
m_ncurrSel = -1;
	//}}AFX_DATA_INIT
}


void SSeOdInfoDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(SSeOdInfoDlg)
	DDX_Control(pDX, IDC_KSORT_COMB, m_odSoCtr);
	DDX_Control(pDX, IDC_LIST_ODER, m_listCtr);
	DDX_Control(pDX, IDC_KSEARCH_COMB, m_odSeCtr);
	DDX_Text(pDX, IDC_KEY_EDIT, m_kstr);
	DDX_CBIndex(pDX, IDC_KSEARCH_COMB, m_nSearch);
	DDX_CBIndex(pDX, IDC_KSORT_COMB, m_nSort);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(SSeOdInfoDlg, CDialog)
	//{{AFX_MSG_MAP(SSeOdInfoDlg)
	ON_NOTIFY(NM_CLICK, IDC_LIST_ODER, OnClickListOder)
	ON_NOTIFY(NM_DBLCLK, IDC_LIST_ODER, OnDblclkListOder)
	ON_BN_CLICKED(IDC_SEARCH_BTN, OnSearchBtn)
	ON_BN_CLICKED(IDC_SORT_BTN, OnSortBtn)
	ON_BN_CLICKED(IDC_CHAN_BNT, OnChanBnt)
	ON_BN_CLICKED(IDC_REFRESH_BNT, OnRefreshBnt)
	ON_BN_CLICKED(IDC_DEL_BNT, OnDelBnt)
	ON_WM_CTLCOLOR()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// SSeOdInfoDlg message handlers
ADOConn conn4;
_bstr_t sSQL4;
BOOL SSeOdInfoDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	//初始化图标
	m_imagelist.Create(16, 16,ILC_MASK,1,4);
	HICON hIcon=AfxGetApp()->LoadIcon(IDI_ICON5);
	m_imagelist.Add(hIcon);

	//初始化列表框表头
	m_listCtr.SetImageList(&m_imagelist,LVSIL_SMALL);
	m_listCtr.InsertColumn(0,  "发货单ID",  LVCFMT_LEFT,100);
	m_listCtr.InsertColumn(1,  "订 单 ID",  LVCFMT_LEFT,100);
	m_listCtr.InsertColumn(2,  "客 户 ID",  LVCFMT_LEFT,100);
	m_listCtr.InsertColumn(3,  "客户名称",  LVCFMT_LEFT,100);
	m_listCtr.InsertColumn(4,  "产 品 ID",  LVCFMT_LEFT,100);
	m_listCtr.InsertColumn(5,  "产品名称",  LVCFMT_LEFT,100);
	m_listCtr.InsertColumn(6,  "订购数量",  LVCFMT_LEFT,80);
	m_listCtr.InsertColumn(7,  "客户联系人",LVCFMT_LEFT,100);
	m_listCtr.InsertColumn(8,  "送货地址",  LVCFMT_LEFT,150);
	m_listCtr.InsertColumn(10, "备  注",    LVCFMT_LEFT,100);
	m_listCtr.InsertColumn(11, "发送状态(Y/N)",    LVCFMT_LEFT,150);
	//-- 设置单列全选,显示网格 -- //
	m_listCtr.SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES);	
	
	m_nSechType = 0;
	this->oSBindList();
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void SSeOdInfoDlg::oSBindList()
{
	ADOConn conn;
	_RecordsetPtr  m_pRecordset;
	_bstr_t vSQL;
	int nItem;
	CString sKey,sort;

	m_listCtr.DeleteAllItems();
	try{
		//如果Concection对象为空,则重新连接 
		if(conn.m_pConn == NULL)  
			conn.OnInitADOConn();

		if(m_odSoCtr.GetCurSel() == 0)//确定排序方式
			sort = "ASC";
	    else 
			sort = "DESC";

		switch(m_nSechType)
		{
		case 0: 
			vSQL = "select consignmentForm.*,OderFormMessage.* from OderFormMessage,consignmentForm where OderFormMessage.oderFormID = consignmentForm.oderFormID order by sendOderID "+sort;
			m_pRecordset = conn.GetRecordSet(vSQL);	
			break;
		case 1: 
			vSQL="select consignmentForm.*,OderFormMessage.* from OderFormMessage,consignmentForm where OderFormMessage.oderFormID = consignmentForm.oderFormID and sendOderID='" +m_kstr+ "' order by sendOderID "+sort;
			m_pRecordset = conn.GetRecordSet(vSQL);
			break;
		case 2: 
			vSQL= "select consignmentForm.*,OderFormMessage.* from OderFormMessage,consignmentForm where OderFormMessage.oderFormID = consignmentForm.oderFormID and consignmentForm.oderFormID='" +m_kstr+ "'order by sendOderID "+sort;
			m_pRecordset = conn.GetRecordSet(vSQL);
			break;
		case 3:
			vSQL= "select consignmentForm.sendOderID,consignmentForm.orderstate,OderFormMessage.* from OderFormMessage,consignmentForm where OderFormMessage.oderFormID = consignmentForm.oderFormID and clientID='" +m_kstr+ "'order by sendOderID "+sort;
			m_pRecordset = conn.GetRecordSet(vSQL);	
			break;
		case 4:
			vSQL= "select consignmentForm.sendOderID,consignmentForm.orderstate,OderFormMessage.* from OderFormMessage,consignmentForm where OderFormMessage.oderFormID = consignmentForm.oderFormID and productID='" +m_kstr+ "'order by sendOderID "+sort;
			m_pRecordset = conn.GetRecordSet(vSQL);	
			break;
		case 5:
			vSQL= "select consignmentForm.sendOderID,consignmentForm.orderstate,OderFormMessage.* from OderFormMessage,consignmentForm where OderFormMessage.oderFormID = consignmentForm.oderFormID and orderstate='" +m_kstr+ "'order by sendOderID "+sort;
			m_pRecordset = conn.GetRecordSet(vSQL);	
			break;
		default:
			vSQL = "select consignmentForm.sendOderID,consignmentForm.orderstate,OderFormMessage.* from OderFormMessage,consignmentForm where OderFormMessage.oderFormID = consignmentForm.oderFormID order by sendOderID "+sort;
			m_pRecordset = conn.GetRecordSet(vSQL);	
			break;
/**/		}
		while(!m_pRecordset->adoEOF)
		{
			conn.vSID = m_pRecordset->GetCollect("sendOderID");
			conn.vOID = m_pRecordset->GetCollect("oderFormID");
			conn.vCID = m_pRecordset->GetCollect("clientID");
			conn.vCN  = m_pRecordset->GetCollect("clientName");
			conn.vPID = m_pRecordset->GetCollect("productID");
			conn.vPN = m_pRecordset->GetCollect("productName");
			conn.vOPNUM = m_pRecordset->GetCollect("productNum");
			conn.vClP = m_pRecordset->GetCollect("clientContactPerson");	
			conn.vTRADD = m_pRecordset->GetCollect("consignmentAddress");//AfxMessageBox("ok");
			conn.vREMARK = m_pRecordset->GetCollect("remark");
			conn.vOS = m_pRecordset->GetCollect("orderstate");
			// -- 添加数据到列表控件中 -- //
			
			nItem = m_listCtr.InsertItem(0xffff,(_bstr_t)conn.vSID,0);//;
			m_listCtr.SetItemText(nItem,1,(_bstr_t)conn.vOID);//;
			m_listCtr.SetItemText(nItem,2,(_bstr_t)conn.vCID);	
			m_listCtr.SetItemText(nItem,3,(_bstr_t)conn.vCN);
			m_listCtr.SetItemText(nItem,4,(_bstr_t)conn.vPID);
			m_listCtr.SetItemText(nItem,5,(_bstr_t)conn.vPN);
			m_listCtr.SetItemText(nItem,6,(_bstr_t)conn.vOPNUM);
			m_listCtr.SetItemText(nItem,7,(_bstr_t)conn.vClP);
			m_listCtr.SetItemText(nItem,8,(_bstr_t)conn.vTRADD);
			m_listCtr.SetItemText(nItem,9,(_bstr_t)conn.vREMARK);
			m_listCtr.SetItemText(nItem,10,(_bstr_t)conn.vOS);

			m_pRecordset->MoveNext();
		}
		m_pRecordset->Close();
	}
	catch(_com_error e)
	{
		AfxMessageBox(e.ErrorMessage());
	}
}

void SSeOdInfoDlg::OnClickListOder(NMHDR* pNMHDR, LRESULT* pResult) 
{
	//m_ncurrSel = -1;
	
	//获当前行值
	NM_LISTVIEW *pNMListView = (NM_LISTVIEW *)pNMHDR;
	m_ncurrSel = pNMListView->iItem;
	CString str;
	str.Format("%d",m_ncurrSel);
//	AfxMessageBox(str);

//	m_ncurrSel = m_listCtr.GetSelectionMark();
	if(m_ncurrSel >= 0)
	{
		IID = m_listCtr.GetItemText(m_ncurrSel,0);//取当前项的订单号,0表示列号
	}
	*pResult = 0;
}

void SSeOdInfoDlg::OnDblclkListOder(NMHDR* pNMHDR, LRESULT* pResult) 
{
	SeOdInfoDlg sMod;
	m_ncurrSel = -1;
////	m_ncurrSel = m_listCtr.GetSelectionMark();
	//获当前行值m_ncurrSel
	NM_LISTVIEW *pNMListView = (NM_LISTVIEW *)pNMHDR;
	m_ncurrSel = pNMListView->iItem;

/*	CString str;
	str.Format("m_ncurrSel%d",m_ncurrSel);
	AfxMessageBox(str);
*/
	if(m_ncurrSel >= 0)
	{
		for(int i=0;i<11;i++)
			sMod.s[i] = m_listCtr.GetItemText(m_ncurrSel,i);
		sMod.DoModal();
	}
	else
	{
		AfxMessageBox("请在列表中选中要操作的项!");
	}
	*pResult = 0;
m_ncurrSel = -1;
SSeOdInfoDlg::OnRefreshBnt();
}


void SSeOdInfoDlg::OnSearchBtn() 
{
UpdateData(true);
    switch(m_odSeCtr.GetCurSel())
	{
	 case 0: m_nSechType =1;break;
	 case 1: m_nSechType =2;break;
	 case 2: m_nSechType =3;break;
	 case 3: m_nSechType =4;break;
	 case 4: m_nSechType =5;break;
	 default: break;
	}
	this->oSBindList();	
}

void SSeOdInfoDlg::OnSortBtn() 
{
this->OnSearchBtn();	
}

void SSeOdInfoDlg::OnChanBnt() 
{
	AfxMessageBox("请双击要操作的项!");	
}

void SSeOdInfoDlg::OnRefreshBnt() 
{
	m_nSearch = -1;
	m_nSort = -1;
	m_kstr  = "";
	UpdateData(false);
	m_ncurrSel=-1;
	m_nSechType = 0;
	this->oSBindList();	
}

void SSeOdInfoDlg::OnDelBnt() 
{
if(m_ncurrSel < 0)
			AfxMessageBox("请在列表中选中要删除的项!");
		else
		{
			if(MessageBox("是否确定删除?","请确认",MB_YESNO) == IDYES)
			{
			try
			{
				if(conn4.m_pConn == NULL)  
					conn4.OnInitADOConn();
				SendFormDel(IID);

			}
			catch(_com_error e)
			{
				AfxMessageBox(e.Description());
			}
			}
		}	
}
//删除发货单
void SSeOdInfoDlg::SendFormDel(CString pID)
{
	sSQL4 = "DELETE  FROM consignmentForm WHERE sendOderID='"+pID+"'";
    if(conn4.ExecuteSQL(sSQL4))
    {
		AfxMessageBox("发货单删除!");
		m_nSechType = 0;
		oSBindList();
    }
}
HBRUSH SSeOdInfoDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
{
		//HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
	
COLORREF backColor = RGB(231, 231, 231); //office 2003背景色 
pDC->SetBkMode(TRANSPARENT);                //设置控件背景透明 
return CreateSolidBrush(backColor);            //创建背景刷子 	
	// TODO: Return a different brush if the default is not desired
	//return hbr;

	//HBRUSH hbr = CDialog::OnCtlColor(pDC,pWnd,nCtlColor); 
//pDC->SetBkMode(TRANSPARENT);   
//return    (HBRUSH)GetStockObject(NULL_BRUSH);  
}

void SSeOdInfoDlg::OnCancel() 
{
//if(MessageBox("是否确定退出?","请确认",MB_YESNO) == IDYES)
	//{	
	CDialog::OnCancel();
//}
}

⌨️ 快捷键说明

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