📄 sendoderdlg.cpp
字号:
// SendOderDlg.cpp : implementation file
//
#include "stdafx.h"
#include "ordermanagement.h"
#include "SendOderDlg.h"
#include "ADOConn.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// SendOderDlg dialog
SendOderDlg::SendOderDlg(CWnd* pParent /*=NULL*/)
: CDialog(SendOderDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(SendOderDlg)
m_str1 = _T("");
m_str10 = _T("");
m_str2 = _T("");
m_str3 = _T("");
m_str4 = _T("");
m_str5 = _T("");
m_str6 = _T("");
m_str7 = _T("");
m_str8 = _T("");
m_kstr = _T("");
m_str9 = _T("");
m_nSearch = -1;
m_nSort = -1;
m_str11 = _T("");
//}}AFX_DATA_INIT
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void SendOderDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(SendOderDlg)
DDX_Control(pDX, IDC_SORT_BTN, m_nSo);
DDX_Control(pDX, IDC_SEARCH_BTN, m_nSe);
DDX_Control(pDX, IDC_LIST_SENDODER, m_listCtr);
DDX_Control(pDX, IDC_KSORT_COMB, m_odSoCtr);
DDX_Control(pDX, IDC_KSEARCH_COMB, m_odSeCtr);
DDX_Control(pDX, IDC_KEY_EDIT, m_kstrCtr);
DDX_Text(pDX, IDC_EDIT1, m_str1);
DDX_Text(pDX, IDC_EDIT10, m_str10);
DDX_Text(pDX, IDC_EDIT2, m_str2);
DDX_Text(pDX, IDC_EDIT3, m_str3);
DDX_Text(pDX, IDC_EDIT4, m_str4);
DDX_Text(pDX, IDC_EDIT5, m_str5);
DDX_Text(pDX, IDC_EDIT6, m_str6);
DDX_Text(pDX, IDC_EDIT7, m_str7);
DDX_Text(pDX, IDC_EDIT8, m_str8);
DDX_Text(pDX, IDC_KEY_EDIT, m_kstr);
DDX_Text(pDX, IDC_EDIT9, m_str9);
DDX_CBIndex(pDX, IDC_KSEARCH_COMB, m_nSearch);
DDX_CBIndex(pDX, IDC_KSORT_COMB, m_nSort);
DDX_Text(pDX, IDC_EDIT11, m_str11);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(SendOderDlg, CDialog)
//{{AFX_MSG_MAP(SendOderDlg)
ON_NOTIFY(NM_CLICK, IDC_LIST_SENDODER, OnClickListSendoder)
ON_EN_KILLFOCUS(IDC_KEY_EDIT, OnKillfocusKeyEdit)
ON_BN_CLICKED(IDC_SEARCH_BTN, OnSearchBtn)
ON_BN_CLICKED(IDC_SORT_BTN, OnSortBtn)
ON_BN_CLICKED(IDC_BTN_REFRESH, OnBtnRefresh)
ON_BN_CLICKED(IDC_ONCANCLE, OnOncancle)
ON_WM_CTLCOLOR()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// SendOderDlg message handlers
void SendOderDlg::OnBtnRefresh()
{
m_nSearch = -1;
m_nSort = -1;
m_kstr = "";
m_str1 = "";
m_str2 = "";
m_str3 = "";
m_str4 = "";
m_str5 = "";
m_str6 = "";
m_str7 = "";
m_str8 = "";
m_str9 = "";
m_str10 = "";
m_str11 = "";
UpdateData(false);
m_nSechType = 0;
this->oSBindList();
}
void SendOderDlg::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 SendOderDlg::OnSortBtn()
{
m_nSechType =0;
this->oSBindList();
}
void SendOderDlg::OnClickListSendoder(NMHDR* pNMHDR, LRESULT* pResult)
{
CString s[12];
int num = m_listCtr.GetSelectionMark();//获当前行值
for(int i=0;i <= 11;i++)
{
s[i] = m_listCtr.GetItemText(num,i);//"i"表示列号
}
m_str1 = s[0];
m_str2 = s[1];
m_str3 = s[2];
m_str4 = s[3];
m_str5 = s[4];
m_str6 = s[5];
m_str7 = s[6];
m_str8 = s[7];
m_str9 = s[8];
m_str10 = s[9];
m_str11 = s[10];
UpdateData(false);
*pResult = 0;
}
void SendOderDlg::OnKillfocusKeyEdit()
{
m_nSe.SetFocus();
}
void SendOderDlg::OnOncancle()
{
// TODO: Add your control notification handler code here
//if(MessageBox("是否确定退出?","请确认",MB_YESNO) == IDYES)
//{
CDialog::OnCancel();
//}
}
BOOL SendOderDlg::OnInitDialog()
{
CDialog::OnInitDialog();
//添加窗口图标
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
//初始化图标
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 SendOderDlg::oSBindList()
{
ADOConn conn;
_RecordsetPtr m_pRecordset;
_bstr_t vSQL;
int nItem;
CString sKey,sort;
m_listCtr.DeleteAllItems();
vSQL ="select * from ClientMessage where currState=1";
m_pRecordset = conn.GetRecordSet(vSQL);
conn.vCID = m_pRecordset->GetCollect("clientID");
CString cliID = (char *)(_bstr_t)conn.vCID;
if(m_odSoCtr.GetCurSel() == 0)//确定排序方式
sort = "ASC";
else
sort = "DESC";
try{
//如果Concection对象为空,则重新连接
if(conn.m_pConn == NULL)
conn.OnInitADOConn();
switch(m_nSechType)
{
case 0:
vSQL = "select consignmentForm.*,OderFormMessage.* from OderFormMessage,consignmentForm where OderFormMessage.oderFormID = consignmentForm.oderFormID and OderFormMessage.clientID='"+cliID+"'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+ "' and OderFormMessage.clientID='"+cliID+"'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+ "' and OderFormMessage.clientID='"+cliID+"'order by sendOderID "+sort;
m_pRecordset = conn.GetRecordSet(vSQL);
break;
case 3:
vSQL= "select consignmentForm.*,OderFormMessage.* from OderFormMessage,consignmentForm where OderFormMessage.oderFormID = consignmentForm.oderFormID and clientID='" +m_kstr+ "' and OderFormMessage.clientID='"+cliID+"'order by sendOderID "+sort;
m_pRecordset = conn.GetRecordSet(vSQL);
break;
case 4:
vSQL= "select consignmentForm.*,OderFormMessage.* from OderFormMessage,consignmentForm where OderFormMessage.oderFormID = consignmentForm.oderFormID and productID='" +m_kstr+ "' and OderFormMessage.clientID='"+cliID+"'order by sendOderID "+sort;
m_pRecordset = conn.GetRecordSet(vSQL);
break;
case 5:
vSQL= "select consignmentForm.*,OderFormMessage.* from OderFormMessage,consignmentForm where OderFormMessage.oderFormID = consignmentForm.oderFormID and orderstate='" +m_kstr+ "' and OderFormMessage.clientID='"+cliID+"'order by sendOderID "+sort;
m_pRecordset = conn.GetRecordSet(vSQL);
break;
default:
vSQL = "select consignmentForm.*,OderFormMessage.* from OderFormMessage,consignmentForm where OderFormMessage.oderFormID = consignmentForm.oderFormID and OderFormMessage.clientID='"+cliID+"' 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());
}
}
HBRUSH SendOderDlg::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);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -