【VC开源代码栏目提醒】:网学会员为广大网友收集整理了,DlgStoreUpDown3.cpp,希望对大家有所帮助!
// DlgStoreUpDown3.cpp : implementation file
//
#include "stdafx.h"
#include "aaa.h"
#include "DlgStoreUpDown3.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern _ConnectionPtr m_pCon;
extern _RecordsetPtr m_pRs;
extern CAaaApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CDlgStoreUpDown3 dialog
CDlgStoreUpDown3::CDlgStoreUpDown3(CWnd* pParent /*=NULL*/)
: CDialog(CDlgStoreUpDown3::IDD, pParent)
{
//{{AFX_DATA_INIT(CDlgStoreUpDown3)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CDlgStoreUpDown3::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlgStoreUpDown3)
DDX_Control(pDX, IDC_LIST1, m_list);
DDX_Control(pDX, IDC_EDIT2, m_downlimit);
DDX_Control(pDX, IDC_EDIT1, m_uplimit);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDlgStoreUpDown3, CDialog)
//{{AFX_MSG_MAP(CDlgStoreUpDown3)
ON_NOTIFY(NM_DBLCLK, IDC_LIST1, OnDblclkList1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDlgStoreUpDown3 message handlers
BOOL CDlgStoreUpDown3::OnInitDialog()
{
CDialog::OnInitDialog();
m_list.SetExtendedStyle(LVS_EX_FLATSB|LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES);
m_list.InsertColumn(0,"仓库名称",LVCFMT_LEFT,120);
m_list.InsertColumn(1,"商品编号",LVCFMT_LEFT,100);
m_list.InsertColumn(2,"库存上限",LVCFMT_LEFT,100);
m_list.InsertColumn(3,"库存下限",LVCFMT_LEFT,100);
m_list.ModifyStyle(0,LVS_SHOWSELALWAYS);
//加载信息
LoadInfo();
return TRUE;
}
void CDlgStoreUpDown3::LoadInfo()
{
m_pRs->raw_Close();
CString sql;
sql = "select storagename,merchandiseid,upperlimit,lowerlimit from tb_merchandisestorage";
m_pRs->Open((_variant_t)sql,m_pCon.GetInterfacePtr(),adOpenKeyset,adLockOptimistic,adCmdText);
m_list.DeleteAllItems();
int i,row = 0;
while (!m_pRs->adoEOF)
{
m_list.InsertItem(100,"");
for (i=0;i<4;i++)
{
m_list.SetItemText(row,i,(TCHAR*)(_bstr_t)m_pRs->GetFields()->GetItem((long)i)->Value);
}
row +=1;
m_pRs->MoveNext();
}
}
void CDlgStoreUpDown3::OnDblclkList1(NMHDR* pNMHDR, LRESULT* pResult)
{
int row = m_list.GetSelectionMark();
if (row != -1)
{
CString c_uplimit,c_downlimit;
c_uplimit = m_list.GetItemText(row,2);
c_downlimit = m_list.GetItemText(row,3);
m_downlimit.SetWindowText(c_downlimit);
m_uplimit.SetWindowText(c_uplimit);
}
}
void CDlgStoreUpDown3::CancelOperate()
{
m_uplimit.SetWindowText("");
m_downlimit.SetWindowText("");
m_list.DeleteAllItems();
LoadInfo();
}
void CDlgStoreUpDown3::AddOperate()
{
int row = m_list.GetSelectionMark();
if (row != -1)
{
CString c_uplimit,c_downlimit;
m_uplimit.GetWindowText(c_uplimit);
m_downlimit.GetWindowText(c_downlimit);
if (c_uplimit.IsEmpty()||c_downlimit.IsEmpty())
{
MessageBox("请设置库存上下限信息.","提示",64);
return;
}
float f_uplimit,f_downlimit;
CString c_merchandiseid,c_storagename;
c_storagename = m_list.GetItemText(row,0);
c_merchandiseid = m_list.GetItemText(row,1);
f_uplimit = atof(c_uplimit);
f_downlimit = atof(c_downlimit);
CString sql;
sql.Format("update tb_merchandisestorage set upperlimit = %f,lowerlimit = %f where merchandiseid = '%s' and storagename = '%s' ",f_uplimit,f_downlimit,c_merchandiseid,c_storagename);
try
{
m_pRs->raw_Close();
m_pRs->Open((_variant_t)sql,m_pCon.GetInterfacePtr(),adOpenKeyset,adLockOptimi