📄 verify.cpp
字号:
// VERIFY.cpp : 实现文件
//
#include "stdafx.h"
#include "VERIFY.h"
extern _ConnectionPtr pMyConnect;
extern CString str_select_outcomebillno;
extern CString str_select_outcomebrand;
extern CString str_select_outcomemode;
extern CString str_select_outcomenumber;
extern CString str_select_typesn ;
extern CString str_username;
// CVERIFY 对话框
IMPLEMENT_DYNAMIC(CVERIFY, CDialog)
CVERIFY::CVERIFY(CWnd* pParent /*=NULL*/)
: CDialog(CVERIFY::IDD, pParent)
{
}
CVERIFY::~CVERIFY()
{
}
void CVERIFY::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CVERIFY, CDialog)
ON_BN_CLICKED(IDOK, &CVERIFY::OnBnClickedOk)
END_MESSAGE_MAP()
// CVERIFY 消息处理程序
BOOL CVERIFY::OnInitDialog()
{
CDialog::OnInitDialog();
CComboBox* pWnd;
pWnd = (CComboBox*)GetDlgItem(IDC_COMBO_VERIFY);
pWnd->ResetContent();
pWnd->InsertString(0,_T("通过"));
pWnd->InsertString(1,_T("未通过"));
return FALSE;// 将焦点设置到控件,否则返回 TRUE
}
void CVERIFY::OnBnClickedOk()
{
// TODO: 在此添加控件通知处理程序代码
CWnd* pWnd;
CString str_result = _T("");
pWnd = GetDlgItem(IDC_COMBO_VERIFY);
pWnd->GetWindowText(str_result);
if ( str_result.GetLength() == 0 )
{
AfxMessageBox(_T("请选择经审核结果!"));
return;
}
CString str_type_sn = str_select_typesn;
_RecordsetPtr m_pRs;
CString m_strSql;
_variant_t RecordsAffected;
bool bSuccess = FALSE;
if( str_result == _T("通过") )
{
bool bHadItem = FALSE;
bool bEnough = FALSE;
m_strSql.Format(_T("select NUMBER from STORAGE_TABLE where ( STORAGE_TYPE_SN ='") +str_type_sn+ _T("' and BRAND='") + str_select_outcomebrand + _T("' and MODE='") +str_select_outcomemode+ _T("')") );
m_pRs.CreateInstance( __uuidof(Recordset) );
m_pRs->Open( _bstr_t(m_strSql), _variant_t((IDispatch *)pMyConnect,true), adOpenKeyset, adLockOptimistic, adCmdText);
try
{
if ( m_pRs->GetRecordCount() > 0 )
{
m_pRs->MoveFirst();
while(m_pRs->adoEOF==VARIANT_FALSE)
{
//Retrieve column's value:
_variant_t TheValue;
TheValue = m_pRs->Fields->GetItem(_variant_t("NUMBER"))->Value;
if(TheValue.vt != VT_NULL)
{
_bstr_t s1=(_bstr_t)TheValue;
CString str_number = s1;
int ioldNumber = _wtoi(str_number);
int iaddNumber = _wtoi(str_select_outcomenumber);
if ( ioldNumber > iaddNumber)
{
bHadItem = TRUE;
}
else
{
bHadItem = FALSE;
}
if( (ioldNumber < iaddNumber) )
{
bEnough= FALSE;
}
else
{
bEnough = TRUE;
}
int inewNumber = ioldNumber - iaddNumber;
str_select_outcomenumber.Format(_T("%d"),inewNumber);
}
//Do something what you want to do: ......
m_pRs->MoveNext();
}
}
}
catch (_com_error &e)
{
::MessageBox(NULL,e.Description(),(LPCTSTR)(_T("警告")),MB_OK);
}
m_pRs->Close();
if ( !bEnough )
{
AfxMessageBox(_T("出库数量大于库存数量,请重输出库数量!"));
return;
}
if ( bHadItem )
{
m_strSql.Format(_T("update STORAGE_TABLE SET NUMBER=") + str_select_outcomenumber + _T(" WHERE ( STORAGE_TYPE_SN ='") +str_type_sn+ _T("' and BRAND='") + str_select_outcomebrand + _T("' and MODE='") +str_select_outcomemode+ _T("')") );
}
else
{
m_strSql.Format(_T("delete from STORAGE_TABLE where(STORAGE_TYPE_SN ='") +str_type_sn+ _T("' and BRAND='") + str_select_outcomebrand + _T("' and MODE='") +str_select_outcomemode+ _T("')") );
}
bSuccess = pMyConnect->Execute(_bstr_t(m_strSql),&RecordsAffected,adCmdText);
if( !bSuccess )
{
AfxMessageBox(_T("更新库存失败,请重启系统!"));
return;
}
AfxMessageBox(_T("更新库存成功!"));
CString str_currenttime;
CTime CurrentTime = CTime::GetCurrentTime();
str_currenttime.Format(_T("%04d-%02d-%02d "),CurrentTime.GetYear(), CurrentTime.GetMonth(),CurrentTime.GetDay());
m_strSql.Format( _T("update INOUT_TABLE SET ISVERIFY='已审核',VERIFY_NAME='") +str_username+ _T("',VERIFY_DATE='") +str_currenttime+ _T("' WHERE ( BILL_NO='") +str_select_outcomebillno+ _T("')") );
bSuccess = pMyConnect->Execute(_bstr_t(m_strSql),&RecordsAffected,adCmdText);
if( !bSuccess )
{
AfxMessageBox(_T("更新出库单审核状态失败,请联系系统管理检查数据库!"));
return;
}
AfxMessageBox(_T("审核成功!"));
}
if( str_result == _T("未通过") )
{
m_strSql.Format( _T("delete from INOUT_TABLE where ( BILL_NO='") +str_select_outcomebillno+ _T("')") );
bSuccess = pMyConnect->Execute(_bstr_t(m_strSql),&RecordsAffected,adCmdText);
if( !bSuccess )
{
AfxMessageBox(_T("删除未通过审核单失败,请重启系统!"));
return;
}
AfxMessageBox(_T("审核成功,此单将从数据库中删除!"));
}
OnOK();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -