📄 supplysearch.cpp
字号:
// SupplySearch.cpp : implementation file
//
#include "stdafx.h"
#include "Toolmangne.h"
#include "SupplySearch.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// SupplySearch dialog
extern CToolmangneApp theApp;
SupplySearch::SupplySearch(CWnd* pParent /*=NULL*/)
: CDialog(SupplySearch::IDD, pParent)
{
//{{AFX_DATA_INIT(SupplySearch)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void SupplySearch::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(SupplySearch)
DDX_Control(pDX, IDC_LIST1, m_supply);
//}}AFX_DATA_MAP
init();
}
BEGIN_MESSAGE_MAP(SupplySearch, CDialog)
//{{AFX_MSG_MAP(SupplySearch)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// SupplySearch message handlers
void SupplySearch::OnOK()
{
// TODO: Add extra validation here
//CDialog::OnOK();
CString sql = "select * from OfferToBuy";
//CString sql = "UPDATE Provider Set PassWord ='"+m_pass+"',Address='"+m_addr+"',Tel='"+m_tell+"',Intro='"+m_info+"' WHERE ID="+UserId;
_RecordsetPtr m_pRecordset;
m_pRecordset.CreateInstance(__uuidof(Recordset));
_variant_t RecordsAffected;
try
{
m_pRecordset->Open(_variant_t(sql), // 查询DemoTable表中所有字段
theApp.m_pConnection.GetInterfacePtr(), // 获取库接库的IDispatch指针
adOpenDynamic,
adLockOptimistic,
adCmdText);
_variant_t var;
if(!m_pRecordset->BOF)
m_pRecordset->MoveFirst();
else
{
AfxMessageBox("没有需求");
return ;
}
// 读入库中各字段并加入列表框中
CString tmp[4];
while(!m_pRecordset->adoEOF)
{
var = m_pRecordset->GetCollect("CustomerID");
if(var.vt != VT_NULL)
tmp[0] = (LPCSTR)_bstr_t(var);
var = m_pRecordset->GetCollect("PartID");
if(var.vt != VT_NULL)
tmp[1] = (LPCSTR)_bstr_t(var);
var = m_pRecordset->GetCollect("Price");
if(var.vt != VT_NULL)
tmp[2] = (LPCSTR)_bstr_t(var);
var = m_pRecordset->GetCollect("Quantity");
if(var.vt != VT_NULL)
tmp[3] = (LPCSTR)_bstr_t(var);
adddata(tmp[1],tmp[2],tmp[3],tmp[0]);
m_pRecordset->MoveNext();
}
}
catch(...)
{
AfxMessageBox("查询失败");
return ;
}
}
void SupplySearch::OnInitialUpdate()
{
}
void SupplySearch::init()
{
m_supply.InsertColumn(0,_T("求购零件号"),LVCFMT_LEFT,0); //插入列
m_supply.InsertColumn(1,_T("价格"),LVCFMT_LEFT,0);
m_supply.InsertColumn(2,_T("数量"),LVCFMT_LEFT,0);
m_supply.InsertColumn(3,_T("求购人ID"),LVCFMT_LEFT,0);
CRect rect4;
m_supply.GetClientRect(rect4); //获得当前客户区信息
m_supply.SetColumnWidth(0,rect4.Width()/4); //设置列的宽度。
m_supply.SetColumnWidth(1,rect4.Width()/4);
m_supply.SetColumnWidth(2,rect4.Width()/4);
m_supply.SetColumnWidth(3,rect4.Width()/4);
//SetStyle(&m_supply);
}
void SupplySearch::SetStyle(CListCtrl * plist)
{
DWORD dwsty = GetWindowLong(plist->m_hWnd,GWL_STYLE);
dwsty &=~(LVS_TYPEMASK);
dwsty &=~(LVS_EDITLABELS);
SetWindowLong(plist->m_hWnd,GWL_STYLE,dwsty|LVS_REPORT|LVS_NOLABELWRAP|LVS_SHOWSELALWAYS);
DWORD sys = LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES;
ListView_SetExtendedListViewStyleEx(plist->m_hWnd,sys,sys);
}
void SupplySearch::adddata(CString id, CString price, CString num, CString cusid)
{
LV_ITEM lvitem;
lvitem.pszText=_T("");
lvitem.mask=LVIF_TEXT;
lvitem.iSubItem=0;
lvitem.iItem=0;
m_supply.InsertItem(&lvitem);
m_supply.SetItemText(0,0,id);
m_supply.SetItemText(0,1,price);
m_supply.SetItemText(0,2,num);
m_supply.SetItemText(0,3,cusid);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -