📄 enterdlg.cpp
字号:
// EnterDlg.cpp : implementation file
//
#include "stdafx.h"
#include "QGZX_InfoPlat.h"
#include "EnterDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CEnterDlg dialog
CEnterDlg::CEnterDlg(CWnd* pParent /*=NULL*/)
: CDialog(CEnterDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CEnterDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
nOpenType = 0;
m_ds = new CData();
m_ds->InitData();
}
void CEnterDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CEnterDlg)
DDX_Control(pDX, IDC_LIST_GOODS, m_listGood);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CEnterDlg, CDialog)
//{{AFX_MSG_MAP(CEnterDlg)
ON_NOTIFY(NM_CLICK, IDC_LIST_GOODS, OnClickListGoods)
ON_BN_CLICKED(IDC_BTN_NEW, OnBtnNew)
ON_MESSAGE(WM_REFRESHLIST, OnRefreshListView)
ON_BN_CLICKED(IDC_BTN_DEL, OnBtnDel)
ON_BN_CLICKED(IDC_BTN_REFRESH, OnBtnRefresh)
ON_BN_CLICKED(IDC_BTN_FASTSEARCH, OnBtnFastsearch)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CEnterDlg message handlers
void CEnterDlg::OnOK()
{
// TODO: Add extra validation here
CDialog::OnOK();
}
void CEnterDlg::OnCancel()
{
// TODO: Add extra cleanup here
CDialog::OnCancel();
}
BOOL CEnterDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
if(this->nOpenType == 2)
{
((CButton*)GetDlgItem(IDC_BTN_NEW))->EnableWindow(FALSE);
((CButton*)GetDlgItem(IDC_BTN_ALTER))->EnableWindow(FALSE);
((CButton*)GetDlgItem(IDC_BTN_SEARCH))->EnableWindow(FALSE);
((CButton*)GetDlgItem(IDC_BTN_DEL))->EnableWindow(FALSE);
SetWindowText("商品信息快速查询");
}
m_listGood.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);
m_listGood.InsertColumn(0, "商品编号", LVCFMT_LEFT, 80);
m_listGood.InsertColumn(1, "商品名称", LVCFMT_LEFT, 130);
m_listGood.InsertColumn(2, "所属分类", LVCFMT_LEFT, 80);
m_listGood.InsertColumn(3, "库存数量", LVCFMT_LEFT, 60);
m_listGood.InsertColumn(4, "出货价格", LVCFMT_LEFT, 80);
m_listGood.InsertColumn(5, "存储位置", LVCFMT_LEFT, 100);
m_listGood.InsertColumn(6, "商品信息", LVCFMT_LEFT, 80);
m_listGood.InsertColumn(7, "最近进货日期", LVCFMT_LEFT, 80);
m_listGood.InsertColumn(8, "总计入库", LVCFMT_LEFT, 60);
m_listGood.InsertColumn(9, "卖出数量", LVCFMT_LEFT, 60);
m_listGood.InsertColumn(10, "作废数量", LVCFMT_LEFT, 60);
m_listGood.InsertColumn(11, "生产厂商", LVCFMT_LEFT, 90);
RefreshListView(NULL);
// m_listGood.InsertColumn(2, "进货价格", LVCFMT_LEFT, 90);
// RefreshListView(NULL);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
BOOL CEnterDlg::RefreshListView(CListCtrl *listview)
{
int nRecordCount = 0;
m_listGood.DeleteAllItems();
m_ds->ExecuteSQL("SELECT * FROM ClassGood");
nRecordCount = m_ds->GetRecordCount();
for(int i = 0; i < nRecordCount; i++)
{
m_listGood.InsertItem(i, "");
m_listGood.SetItemText(i, 0 , m_ds->GetAsString("GoodID"));
m_listGood.SetItemText(i, 1 , m_ds->GetAsString("GoodName"));
m_listGood.SetItemText(i, 2 , m_ds->GetAsString("ClassName"));
m_listGood.SetItemText(i, 3 , m_ds->GetAsString("StorageNum"));
m_listGood.SetItemText(i, 4 , m_ds->GetAsString("OutPrice"));
m_listGood.SetItemText(i, 5 , m_ds->GetAsString("StorageAddr"));
m_listGood.SetItemText(i, 6 , m_ds->GetAsString("GoodInfo"));
m_listGood.SetItemText(i, 7 , m_ds->GetAsString("LastEnterDate"));
m_listGood.SetItemText(i, 8 , m_ds->GetAsString("EnterSumNum"));
m_listGood.SetItemText(i, 9 , m_ds->GetAsString("SellNum"));
m_listGood.SetItemText(i, 10 , m_ds->GetAsString("DiscardNum"));
m_listGood.SetItemText(i, 11 , m_ds->GetAsString("FacturerID"));
m_ds->MoveNext();
}
return TRUE;
}
void CEnterDlg::OnClickListGoods(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
int nCurRow;
CString str_tmp1;
nCurRow = m_listGood.GetSelectionMark();
str_tmp1 = m_listGood.GetItemText(nCurRow, 8) + " 件";
SetDlgItemText(IDC_STATIC_SUM,str_tmp1);
str_tmp1 = m_listGood.GetItemText(nCurRow, 9) + " 件";
SetDlgItemText(IDC_STATIC_SELL,str_tmp1);
str_tmp1 = m_listGood.GetItemText(nCurRow, 3) + " 件";
SetDlgItemText(IDC_STATIC_CUR,str_tmp1);
str_tmp1 = m_listGood.GetItemText(nCurRow, 10) + " 件";
SetDlgItemText(IDC_STATIC_DIS,str_tmp1);
UpdateData(FALSE);
*pResult = 0;
}
void CEnterDlg::OnBtnNew()
{
// TODO: Add your control notification handler code here
CNewGoodDlg dlg;
dlg.DoModal();
}
void CEnterDlg::OnRefreshListView(WPARAM wParam, LPARAM lParam)
{
this->RefreshListView(NULL);
return;
}
void CEnterDlg::OnBtnDel()
{
// TODO: Add your control notification handler code here
int nCurRow;
CString strGoodID ,strClassName;
CString strSQL;
nCurRow = m_listGood.GetSelectionMark();
strGoodID = m_listGood.GetItemText(nCurRow,0);
strClassName = m_listGood.GetItemText(nCurRow,2);
if(IDOK != MessageBox("确定要删除[" + strGoodID + "]产品吗?","系统提示",MB_OKCANCEL|MB_ICONQUESTION|MB_DEFBUTTON2))
return;
strSQL.Format("Delete From _tGoodsLibrary Where GoodID = '%s'", strGoodID);
m_ds->ExecuteOther(strSQL);
m_listGood.DeleteItem(nCurRow); //比刷新更节省资源
//将类相应类减1
// ::AfxMessageBox(strClassName);
strSQL.Format("Update _tClass set ClassNum = ClassNum - 1 Where ClassName = '%s'", strClassName);
// ::AfxMessageBox(strSQL);
m_ds->ExecuteOther(strSQL);
MessageBox("删除[" + strGoodID + "]成功", "系统提示", MB_ICONINFORMATION | MB_OK);
// this->RefreshListView(NULL);
}
void CEnterDlg::OnBtnRefresh()
{
// TODO: Add your control notification handler code here
this->RefreshListView(NULL);
}
void CEnterDlg::OnBtnFastsearch()
{
// TODO: Add your control notification handler code here
CString strKeyWord, strSQL;
int nCurRowt = 0;
int nRecordCount = 0;
GetDlgItemText(IDC_EDIT_KEYWORD, strKeyWord);
strKeyWord = "%" + strKeyWord + "%";
m_listGood.DeleteAllItems();
if(strKeyWord == "")
{
this->RefreshListView(NULL);
return;
}
else
{
strSQL.Format("Select * From ClassGood Where GoodID like '%s'", strKeyWord);
m_ds->ExecuteSQL(strSQL);
nRecordCount = m_ds->GetRecordCount();
for(int i = 0; i < nRecordCount; i++)
{
m_listGood.InsertItem(nCurRowt, "");
m_listGood.SetItemText(nCurRowt, 0 , m_ds->GetAsString("GoodID"));
m_listGood.SetItemText(nCurRowt, 1 , m_ds->GetAsString("GoodName"));
m_listGood.SetItemText(nCurRowt, 2 , m_ds->GetAsString("ClassName"));
m_listGood.SetItemText(nCurRowt, 3 , m_ds->GetAsString("StorageNum"));
m_listGood.SetItemText(nCurRowt, 4 , m_ds->GetAsString("OutPrice"));
m_listGood.SetItemText(nCurRowt, 5 , m_ds->GetAsString("StorageAddr"));
m_listGood.SetItemText(nCurRowt, 6 , m_ds->GetAsString("GoodInfo"));
m_listGood.SetItemText(nCurRowt, 7 , m_ds->GetAsString("LastEnterDate"));
m_listGood.SetItemText(nCurRowt, 8 , m_ds->GetAsString("EnterSumNum"));
m_listGood.SetItemText(nCurRowt, 9 , m_ds->GetAsString("SellNum"));
m_listGood.SetItemText(nCurRowt, 10 , m_ds->GetAsString("DiscardNum"));
m_listGood.SetItemText(nCurRowt++, 11 , m_ds->GetAsString("FacturerID"));
m_ds->MoveNext();
}
//第二批查询
strSQL.Format("Select * From ClassGood Where GoodName like '%s'", strKeyWord);
m_ds->ExecuteSQL(strSQL);
nRecordCount = m_ds->GetRecordCount();
for(i = 0; i < nRecordCount; i++)
{
m_listGood.InsertItem(nCurRowt, "");
m_listGood.SetItemText(nCurRowt, 0 , m_ds->GetAsString("GoodID"));
m_listGood.SetItemText(nCurRowt, 1 , m_ds->GetAsString("GoodName"));
m_listGood.SetItemText(nCurRowt, 2 , m_ds->GetAsString("ClassName"));
m_listGood.SetItemText(nCurRowt, 3 , m_ds->GetAsString("StorageNum"));
m_listGood.SetItemText(nCurRowt, 4 , m_ds->GetAsString("OutPrice"));
m_listGood.SetItemText(nCurRowt, 5 , m_ds->GetAsString("StorageAddr"));
m_listGood.SetItemText(nCurRowt, 6 , m_ds->GetAsString("GoodInfo"));
m_listGood.SetItemText(nCurRowt, 7 , m_ds->GetAsString("LastEnterDate"));
m_listGood.SetItemText(nCurRowt, 8 , m_ds->GetAsString("EnterSumNum"));
m_listGood.SetItemText(nCurRowt, 9 , m_ds->GetAsString("SellNum"));
m_listGood.SetItemText(nCurRowt, 10 , m_ds->GetAsString("DiscardNum"));
m_listGood.SetItemText(nCurRowt++, 11 , m_ds->GetAsString("FacturerID"));
m_ds->MoveNext();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -