📄 in2.cpp
字号:
// In.cpp : implementation file
//
#include "stdafx.h"
#include "aoManage.h"
#include "In2.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CIn2 dialog
CIn2::CIn2(CWnd* pParent /*=NULL*/)
: CParentDlg(CIn2::IDD, pParent)
{
//{{AFX_DATA_INIT(CIn2)
m_nCount = 0;
m_dtDate = COleDateTime::GetCurrentTime();
m_dtTime = COleDateTime::GetCurrentTime();
m_strWorker = _T("");
m_nRadio = 0;
m_strCode = _T("");
//}}AFX_DATA_INIT
m_pMaterial=new CDaoRecordset(&((CMainFrame*)AfxGetMainWnd())->m_db);
m_pStorage=new CDaoRecordset(&((CMainFrame*)AfxGetMainWnd())->m_db);
m_pProduct=new CDaoRecordset(&((CMainFrame*)AfxGetMainWnd())->m_db);
m_strOperator=((CMainFrame*)AfxGetMainWnd())->m_strOperator;
m_nID=0;
}
void CIn2::DoDataExchange(CDataExchange* pDX)
{
CParentDlg::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CIn2)
DDX_Control(pDX, IDC_COMBO2, m_ctlCbCode);
DDX_Text(pDX, IDC_EDIT2, m_nCount);
DDX_Text(pDX, IDC_EDIT7, m_dtDate);
DDX_Text(pDX, IDC_EDIT8, m_dtTime);
DDX_Text(pDX, IDC_EDIT9, m_strWorker);
DDX_Text(pDX, IDC_EDIT10, m_strOperator);
DDX_Radio(pDX, IDC_RADIO1, m_nRadio);
DDX_CBString(pDX, IDC_COMBO2, m_strCode);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CIn2, CParentDlg)
//{{AFX_MSG_MAP(CIn2)
ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
ON_BN_CLICKED(IDC_BUTTON4, OnButton4)
ON_WM_CLOSE()
ON_BN_CLICKED(IDC_BUTTON8, OnButton8)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CIn2 message handlers
BOOL CIn2::OnInitDialog()
{
CParentDlg::OnInitDialog();
m_pMaterial->Open(AFX_DAO_USE_DEFAULT_TYPE,"select * from material");
m_pStorage->Open(AFX_DAO_USE_DEFAULT_TYPE,"select * from storage");
m_pProduct->Open(AFX_DAO_USE_DEFAULT_TYPE,"select * from product");
CString strFltr;
strFltr.Format("id=%d",m_nID);
m_pStorage->FindFirst(strFltr);
COleVariant vVal;
m_pStorage->GetFieldValue("code",vVal);
CString strTemp;
COleVariant vCode,vName,vType;
strTemp=(LPCTSTR)vVal.bstrVal;
if (strTemp.Left(1)=="1")
while (!m_pMaterial->IsEOF())
{
m_pMaterial->GetFieldValue("pcode",vCode);
m_pMaterial->GetFieldValue("pname",vName);
m_pMaterial->GetFieldValue("ptype",vType);
strTemp=(LPCTSTR)vCode.bstrVal;
strTemp+=" ";
strTemp+=(LPCTSTR)vName.bstrVal;
strTemp+=" ";
strTemp+=(LPCTSTR)vType.bstrVal;
m_ctlCbCode.AddString(strTemp);
m_pMaterial->MoveNext();
}
else
while (!m_pProduct->IsEOF())
{
m_pProduct->GetFieldValue("pcode",vCode);
m_pProduct->GetFieldValue("pname",vName);
strTemp=(LPCTSTR)vCode.bstrVal;
strTemp+=" ";
strTemp+=(LPCTSTR)vName.bstrVal;
m_ctlCbCode.AddString(strTemp);
m_pProduct->MoveNext();
}
m_strCode=(LPCTSTR)vVal.bstrVal;
m_pStorage->GetFieldValue("count",vVal);
m_nCount=vVal.iVal;
m_pStorage->GetFieldValue("ifin",vVal);
m_nRadio=(vVal.bVal==0)?1:0;
m_pStorage->GetFieldValue("sdate",vVal);
m_dtDate=vVal;
m_pStorage->GetFieldValue("stime",vVal);
m_dtTime=vVal;
m_pStorage->GetFieldValue("worker",vVal);
m_strWorker=(LPCTSTR)vVal.bstrVal;
m_pStorage->GetFieldValue("operator",vVal);
m_strOperator=(LPCTSTR)vVal.bstrVal;
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CIn2::OnButton3()
{
if (MessageBox("确实要更改吗?",NULL,MB_OKCANCEL)==IDCANCEL)
return;
UpdateData(TRUE);
if (!m_strCode.GetLength())
{
MessageBox("品号不能为空");
return;
}
if (!(m_nCount>0))
{
MessageBox("数量应大于零");
return;
}
int nCount=0;
m_pStorage->Edit();
m_pStorage->SetFieldValue("code",(LPCTSTR)m_strCode.Left(9));
m_pStorage->SetFieldValue("count",(short)m_nCount);
m_pStorage->SetFieldValue("ifin",BYTE(!m_nRadio));
m_pStorage->SetFieldValue("sdate",m_dtDate);
m_pStorage->SetFieldValue("stime",m_dtTime);
m_pStorage->SetFieldValue("worker",(LPCTSTR)m_strWorker);
m_pStorage->SetFieldValue("operator",(LPCTSTR)m_strOperator);
m_pStorage->Update();
MessageBox("记录已成功修改");
OnOK();
}
void CIn2::OnButton4()
{
OnCancel();
}
void CIn2::OnClose()
{
if (m_pMaterial->IsOpen())
m_pMaterial->Close();
if (m_pStorage->IsOpen())
m_pStorage->Close();
if (m_pProduct->IsOpen())
m_pProduct->Close();
CParentDlg::OnClose();
}
void CIn2::OnButton8()
{
if (MessageBox("确实要修改吗?",NULL,MB_OKCANCEL)==IDOK)
{
m_pStorage->Delete();
MessageBox("记录已被删除");
OnOK();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -