?? dlggoodbadquery4.cpp
字號(hào):
// DlgGoodBadQuery4.cpp : implementation file
//
#include "stdafx.h"
#include "aaa.h"
#include "DlgGoodBadQuery4.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDlgGoodBadQuery4 dialog
CDlgGoodBadQuery4::CDlgGoodBadQuery4(CWnd* pParent /*=NULL*/)
: CDialog(CDlgGoodBadQuery4::IDD, pParent)
{
//{{AFX_DATA_INIT(CDlgGoodBadQuery4)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CDlgGoodBadQuery4::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlgGoodBadQuery4)
DDX_Control(pDX, IDC_LIST1, list);
DDX_Control(pDX, IDC_EDIT1, value);
DDX_Control(pDX, IDC_DATETIMEPICKER2, endtime);
DDX_Control(pDX, IDC_DATETIMEPICKER1, starttime);
DDX_Control(pDX, IDC_COMBO1, fields);
DDX_Control(pDX, IDC_CHECK2, check2);
DDX_Control(pDX, IDC_CHECK1, check1);
DDX_Control(pDX,IDC_CHECKLOSE,checklose);
DDX_Control(pDX,IDC_CHECKMORE,checkmore);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDlgGoodBadQuery4, CDialog)
//{{AFX_MSG_MAP(CDlgGoodBadQuery4)
ON_WM_CLOSE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDlgGoodBadQuery4 message handlers
BOOL CDlgGoodBadQuery4::OnInitDialog()
{
CDialog::OnInitDialog();
checklose.SetCheck(1);//選中報(bào)損按鈕
list.SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES|LVS_EX_FLATSB);
//向表格中添加列
list.InsertColumn(0,"盤點(diǎn)單號(hào)");
list.InsertColumn(1,"倉(cāng)庫(kù)名稱");
list.InsertColumn(2,"商品編號(hào)");
list.InsertColumn(3,"商品名稱");
list.InsertColumn(4,"數(shù)量");
list.SetColumnWidth(0,120);
list.SetColumnWidth(1,100);
list.SetColumnWidth(2,120);
list.SetColumnWidth(3,120);
list.SetColumnWidth(4,100);
return TRUE;
}
void CDlgGoodBadQuery4::OnClose()
{
CDialog::OnClose();
}
void CDlgGoodBadQuery4::CancelQuery()
{
check1.SetCheck(0);
check2.SetCheck(0);
fields.SetCurSel(-1);
checklose.SetCheck(1);
checkmore.SetCheck(0);
value.SetWindowText("");
CTime temp = CTime::GetCurrentTime();
starttime.SetTime(&temp);
endtime.SetTime(&temp);
list.DeleteAllItems();
}
BOOL CDlgGoodBadQuery4::PreTranslateMessage(MSG* pMsg)
{
if (pMsg->message ==WM_KEYDOWN)
{
if (pMsg->wParam==13)
pMsg->wParam = 9;
}
return CDialog::PreTranslateMessage(pMsg);
}
void CDlgGoodBadQuery4::Query()
{
if ((check1.GetCheck() ==false)&&(check2.GetCheck()==false))
{
MessageBox("請(qǐng)?jiān)O(shè)置查詢條件","提示",64);
return;
}
int checkspec = checkmore.GetCheck(); //盤點(diǎn)標(biāo)識(shí)0報(bào)損1報(bào)溢
if ( (check1.GetCheck()==true)&&(check2.GetCheck()==false))
{
CString c_field,c_value;
fields.GetWindowText(c_field);
value.GetWindowText(c_value);
if (c_field.IsEmpty()||(c_value.IsEmpty()))
{
MessageBox("請(qǐng)?jiān)O(shè)置查詢條件","提示",64);
return;
}
CString sql;
list.DeleteAllItems();
switch (fields.GetCurSel())
{
case 0:
{
c_field = "checkid";
sql.Format("select a.checkid,a.storage,b.merchandiseid,c.name,b.sum from tb_check_main a inner join tb_check_sub b on a.checkid = b.checkid inner join tb_merchandiseinfo c on b.merchandiseid = c.id and a.checkspec = %i and a.%s = '%s'",checkspec,c_field,c_value);
break;
}
case 1:
{
c_field = "name";
sql.Format("select a.checkid,a.storage,b.merchandiseid,c.name,b.sum from tb_check_main a inner join tb_check_sub b on a.checkid = b.checkid inner join tb_merchandiseinfo c on b.merchandiseid = c.id and a.checkspec = %i and c.%s = '%s'",checkspec,c_field,c_value);
break;
}
case 2:
{
c_field = "principal";
sql.Format("select a.checkid,a.storage,b.merchandiseid,c.name,b.sum from tb_check_main a inner join tb_check_sub b on a.checkid = b.checkid inner join tb_merchandiseinfo c on b.merchandiseid = c.id and a.checkspec = %i and a.%s = '%s'",checkspec,c_field,c_value);
break;
}
}
m_pRs->raw_Close();
m_pRs->Open((_variant_t)sql,m_pCon.GetInterfacePtr(),adOpenKeyset,adLockOptimistic,adCmdText);
int row = 0;
while (! m_pRs->adoEOF)
{
CString temp;
list.InsertItem(100,"");
for (int i = 0;i<5;i++)
{
temp = (TCHAR *)(_bstr_t)m_pRs->GetFields()->GetItem((long)i)->Value;
list.SetItemText(row,i,temp);
}
m_pRs->MoveNext();
row +=1;
}
}
else if ((check1.GetCheck()==false)&&(check2.GetCheck()==true))
{
list.DeleteAllItems();
CString sql,c_starttime,c_endtime;
starttime.GetWindowText(c_starttime);
endtime.GetWindowText(c_endtime);
sql.Format("select a.checkid,a.storage,b.merchandiseid,c.name,b.sum from tb_check_main a inner join tb_check_sub b on a.checkid = b.checkid inner join tb_merchandiseinfo c on b.merchandiseid = c.id and a.checktime between '%s' and '%s' and a.checkspec = %i ",c_starttime,c_endtime,checkspec);
m_pRs->raw_Close();
m_pRs->Open((_variant_t)sql,m_pCon.GetInterfacePtr(),adOpenKeyset,adLockOptimistic,adCmdText);
int row = 0;
while (! m_pRs->adoEOF)
{
CString temp;
list.InsertItem(100,"");
for (int i = 0;i<5;i++)
{
temp = (TCHAR *)(_bstr_t)m_pRs->GetFields()->GetItem((long)i)->Value;
list.SetItemText(row,i,temp);
}
m_pRs->MoveNext();
row +=1;
}
}
else
{
CString c_field,c_value;
CString sql,c_starttime,c_endtime;
starttime.GetWindowText(c_starttime);
endtime.GetWindowText(c_endtime);
fields.GetWindowText(c_field);
value.GetWindowText(c_value);
if (c_field.IsEmpty()||(c_value.IsEmpty()))
{
MessageBox("請(qǐng)?jiān)O(shè)置查詢條件","提示",64);
return;
}
list.DeleteAllItems();
switch (fields.GetCurSel())
{
case 0:
{
c_field = "checkid";
sql.Format("select a.checkid,a.storage,b.merchandiseid,c.name,b.sum from tb_check_main a inner join tb_check_sub b on a.checkid = b.checkid inner join tb_merchandiseinfo c on b.merchandiseid = c.id and a.checkspec = %i and a.%s = '%s' and a.checktime between '%s' and '%s'",checkspec,c_field,c_value,c_starttime,c_endtime);
break;
}
case 1:
{
c_field = "name";
sql.Format("select a.checkid,a.storage,b.merchandiseid,c.name,b.sum from tb_check_main a inner join tb_check_sub b on a.checkid = b.checkid inner join tb_merchandiseinfo c on b.merchandiseid = c.id and a.checkspec = %i and c.%s = '%s' and a.checktime between '%s' and '%s'",checkspec,c_field,c_value,c_starttime,c_endtime);
break;
}
case 2:
{
c_field = "principal";
sql.Format("select a.checkid,a.storage,b.merchandiseid,c.name,b.sum from tb_check_main a inner join tb_check_sub b on a.checkid = b.checkid inner join tb_merchandiseinfo c on b.merchandiseid = c.id and a.checkspec = %i and a.%s = '%s' and a.checktime between '%s' and '%s'",checkspec,c_field,c_value,c_starttime,c_endtime);
break;
}
}
m_pRs->Close();
m_pRs->Open((_variant_t)sql,m_pCon.GetInterfacePtr(),adOpenKeyset,adLockOptimistic,adCmdText);
int row = 0;
while (! m_pRs->adoEOF)
{
CString temp;
list.InsertItem(100,"");
for (int i = 0;i<5;i++)
{
temp = (TCHAR *)(_bstr_t)m_pRs->GetFields()->GetItem((long)i)->Value;
list.SetItemText(row,i,temp);
}
m_pRs->MoveNext();
row +=1;
}
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -