📄 newgooddlg.cpp
字号:
// NewGoodDlg.cpp : implementation file
//
#include "stdafx.h"
#include "QGZX_InfoPlat.h"
#include "NewGoodDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CNewGoodDlg dialog
CNewGoodDlg::CNewGoodDlg(CWnd* pParent /*=NULL*/)
: CDialog(CNewGoodDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CNewGoodDlg)
m_className = _T("");
m_facturerName = _T("");
m_addr = _T("");
m_enterNum = _T("");
m_enterPrice = _T("");
m_goodID = _T("");
m_goodInfo = _T("");
m_outPrice = _T("");
m_remark = _T("");
m_goodName = _T("");
//}}AFX_DATA_INIT
m_ds = new CData();
m_ds->InitData();
}
void CNewGoodDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CNewGoodDlg)
DDX_Control(pDX, IDC_COMBO_GOODNAME, m_comboGoodName);
DDX_Control(pDX, IDC_COMBO_FACTURERNAME, m_comboFacName);
DDX_Control(pDX, IDC_COMBO_CLASSNAME, m_comboClassName);
DDX_CBString(pDX, IDC_COMBO_CLASSNAME, m_className);
DDX_CBString(pDX, IDC_COMBO_FACTURERNAME, m_facturerName);
DDX_Text(pDX, IDC_EDIT_ADDR, m_addr);
DDX_Text(pDX, IDC_EDIT_ENTERNUM, m_enterNum);
DDX_Text(pDX, IDC_EDIT_ENTERPRICE, m_enterPrice);
DDX_Text(pDX, IDC_EDIT_GOODID, m_goodID);
DDX_Text(pDX, IDC_EDIT_GOODINFO, m_goodInfo);
DDX_Text(pDX, IDC_EDIT_OUTPRICE, m_outPrice);
DDX_Text(pDX, IDC_EDIT_REMARK, m_remark);
DDX_CBString(pDX, IDC_COMBO_GOODNAME, m_goodName);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CNewGoodDlg, CDialog)
//{{AFX_MSG_MAP(CNewGoodDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CNewGoodDlg message handlers
#define WM_REFRESHLIST WM_USER+100
void CNewGoodDlg::OnOK()
{
// TODO: Add extra validation here
UpdateData(TRUE);
CString strSQL;
CString strClassID, strFacturerID, strCurDate;
int nEnterNum = 0;
int nRecordCount = 0;
int nYear, nMonth, nDay;
//获取系统时间
CTime time;
time=CTime::GetCurrentTime();
nYear=time.GetYear();
nMonth=time.GetMonth();
nDay=time.GetDay();
strCurDate.Format("%4d-%02d-%02d", nYear, nMonth, nDay); //保证日期格式
if(this->m_className == "" || this->m_goodID == "" || this->m_goodName == "" || \
this->m_goodInfo == "" || this->m_enterNum == "" || \
this->m_enterPrice == "" || this->m_outPrice == "" || \
this->m_facturerName == "" || this->m_addr == "" || \
this->m_remark == "")
{
MessageBox("提示:提交信息不完整!", "信息不完整", MB_ICONINFORMATION | MB_OK);
return;
}
else
{
strSQL.Format("Select * From _tGoodsLibrary Where GoodName = '%s'", \
this->m_goodName);
m_ds->ExecuteSQL(strSQL);
nRecordCount = m_ds->GetRecordCount();
if(nRecordCount <= 0)
{
MessageBox("提示:先前库存不存在此商品,系统将新建此商品!", "系统提示", MB_ICONINFORMATION | MB_OK);
//获取分类编号
strSQL.Format("Select ClassID From _tClass Where ClassName = '%s'", \
this->m_className);
m_ds->ExecuteSQL(strSQL);
strClassID = m_ds->GetAsString("ClassID");
//获取生产厂商ID
strSQL.Format("Select FacturerID From _tFacturer Where FacturerName = '%s'", \
this->m_facturerName);
m_ds->ExecuteSQL(strSQL);
strFacturerID = m_ds->GetAsString("FacturerID");
//成生插入语句
strSQL.Format("Insert Into _tGoodsLibrary(GoodID, ClassID, GoodFacturerID, \
GoodName, GoodInfo, EnterSumNum, StorageNum, StorageAddr, EnterPrice, \
OutPrice, LastEnterDate) values('%s', '%s', '%s', '%s', '%s', '%s', '%s', \
'%s', '%s', '%s', '%s')", this->m_goodID, strClassID, strFacturerID, \
this->m_goodName, this->m_goodInfo, this->m_enterNum, this->m_enterNum, \
this->m_addr, this->m_enterPrice, this->m_outPrice, strCurDate);
m_ds->ExecuteOther(strSQL);
strSQL.Format("Update _tClass set ClassNum = ClassNum + 1 Where ClassID = '%s'", strClassID);
m_ds->ExecuteOther(strSQL);
MessageBox("提示:入库成功!", "操作成功", MB_ICONINFORMATION | MB_OK);
}
else
{
// MessageBox("提示:先前库存己存在此商品信息,系统将新建此商品!", "系统提示", MB_ICONINFORMATION | MB_OK);
int nEnterNum;
nEnterNum = atoi(this->m_enterNum);
// strSQL.Format("Update _tGoodsLibrary set StorageNum = StorageNum + %d, \
EnterSumNum = EnterSumNum + %d, EnterPrice = %f, OutPrice = %f \
Where GoodName = '%s'", nEnterNum, nEnterNum, fEnterPrice, fOutPrice, this->m_goodName);
strSQL.Format("Update _tGoodsLibrary set StorageNum = StorageNum + %d, \
EnterSumNum = EnterSumNum + %d, EnterPrice = %s, OutPrice = %s Where GoodName = '%s'", nEnterNum, nEnterNum, this->m_enterPrice, this->m_outPrice, this->m_goodName);
::AfxMessageBox(strSQL);
m_ds->ExecuteOther(strSQL);
MessageBox("提示:入库成功!", "操作成功", MB_ICONINFORMATION | MB_OK);
}
/*
//获取入库数量__总计入库+入库数量__库存数量+入库数量
nEnterNum = atoi(this->m_enterNum);
}
CDialog::OnOK();*/
HWND hwd=CWnd::FindWindow(NULL,"商品入库管理")->GetSafeHwnd();
::PostMessage(hwd, WM_REFRESHLIST, 0, 0);
//添加商品编号
strSQL = m_ds->AutoNumber("_tGoodsLibrary", "GoodID", "NO", 1);
this->m_goodID = strSQL;
UpdateData(FALSE);
return;
}
}
void CNewGoodDlg::OnCancel()
{
// TODO: Add extra cleanup here
CDialog::OnCancel();
}
BOOL CNewGoodDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
//初始化类名ComboBox
CString str_tmp1;
int nRecordCount = 0;
this->m_addr = "货柜";
this->m_enterNum = "0";
this->m_enterPrice = "0.00";
this->m_outPrice = "0.00";
this->m_goodInfo = "<无>";
this->m_remark = "<无>";
//添加分类名称
m_ds->ExecuteSQL("Select * From _tClass");
nRecordCount = m_ds->GetRecordCount();
for(int i = 0; i < nRecordCount; i++)
{
str_tmp1 = m_ds->GetAsString("ClassName");
m_comboClassName.InsertString(i,str_tmp1);
m_ds->MoveNext();
}
//加载生产厂商
m_ds->ExecuteSQL("Select * From _tFacturer");
nRecordCount = m_ds->GetRecordCount();
for(i = 0; i < nRecordCount; i++)
{
str_tmp1 = m_ds->GetAsString("FacturerName");
m_comboFacName.InsertString(i,str_tmp1);
m_ds->MoveNext();
}
//加载商品名称
m_ds->ExecuteSQL("Select * From _tGoodsLibrary");
nRecordCount = m_ds->GetRecordCount();
for(i = 0; i < nRecordCount; i++)
{
str_tmp1 = m_ds->GetAsString("GoodName");
m_comboGoodName.InsertString(i,str_tmp1);
m_ds->MoveNext();
}
//添加商品编号
str_tmp1 = m_ds->AutoNumber("_tGoodsLibrary", "GoodID", "NO", 1);
this->m_goodID = str_tmp1;
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -