📄 productloseform.cpp
字号:
// ProductLoseForm.cpp : implementation file
//
#include "stdafx.h"
#include "Store.h"
#include "ProductLoseForm.h"
#include "Affirm.h"
#include "SelectProduct.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CProductLoseForm dialog
CProductLoseForm::CProductLoseForm(CWnd* pParent /*=NULL*/)
: CDialog(CProductLoseForm::IDD, pParent)
{
//{{AFX_DATA_INIT(CProductLoseForm)
m_productLoseFormID = _T("");
m_storeHouseLose = _T("");
m_houseOutType = _T("");
m_formDate = COleDateTime::GetCurrentTime();
m_remark = _T("");
is_search=0;
flag=1;
m_dealer = _T("");
//}}AFX_DATA_INIT
}
void CProductLoseForm::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CProductLoseForm)
DDX_Control(pDX, IDC_dealer, m_dealerCombo);
DDX_Control(pDX, IDC_storeHouseLose, m_storeHouseLoseCombo);
DDX_Control(pDX, IDC_houseOutType, m_houseOutTypeCombo);
DDX_Control(pDX, IDC_LIST1, m_list);
DDX_Text(pDX, IDC_productLoseFormID, m_productLoseFormID);
DDX_CBString(pDX, IDC_storeHouseLose, m_storeHouseLose);
DDX_CBString(pDX, IDC_houseOutType, m_houseOutType);
DDX_DateTimeCtrl(pDX, IDC_formDate, m_formDate);
DDX_Text(pDX, IDC_remark, m_remark);
DDX_CBString(pDX, IDC_dealer, m_dealer);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CProductLoseForm, CDialog)
//{{AFX_MSG_MAP(CProductLoseForm)
ON_NOTIFY(NM_CLICK, IDC_LIST1, OnClickList)
ON_BN_CLICKED(IDC_add, OnAdd)
ON_BN_CLICKED(IDC_modify, OnModify)
ON_BN_CLICKED(IDC_delete, OnDelete)
ON_BN_CLICKED(IDC_addLine, OnAddLine)
ON_BN_CLICKED(IDC_deleteLine, OnDeleteLine)
ON_BN_CLICKED(IDC_save, OnSave)
ON_BN_CLICKED(IDC_cancelation, OnCancelation)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CProductLoseForm message handlers
BOOL CProductLoseForm::OnInitDialog()
{
CDialog::OnInitDialog();
DWORD style;
style=m_list.GetExStyle();
style=(style|LVS_EX_GRIDLINES|LVS_EX_FULLROWSELECT)&(~LVS_EX_CHECKBOXES) ;
m_list.SetExtendedStyle(style);
m_list.InsertColumn(0,"产品编号",LVCFMT_LEFT,100);
m_list.InsertColumn(1,"产品名称",LVCFMT_LEFT,100);
m_list.InsertColumn(2,"产品单位",LVCFMT_LEFT,100);
m_list.InsertColumn(3,"产品型号",LVCFMT_LEFT,100);
m_list.InsertColumn(4,"数量",LVCFMT_LEFT,100);
m_list.InsertColumn(5,"单价",LVCFMT_LEFT,100);
m_list.InsertColumn(6,"金额",LVCFMT_LEFT,100);
bt_add=GetDlgItem(IDC_add);
bt_delete=GetDlgItem(IDC_delete);
bt_modify=GetDlgItem(IDC_modify);
bt_addLine=GetDlgItem(IDC_addLine);
bt_deleteLine=GetDlgItem(IDC_deleteLine);
bt_save=GetDlgItem(IDC_save);
bt_cancelation=GetDlgItem(IDC_cancelation);
tx_productLoseFormID=GetDlgItem(IDC_productLoseFormID);
tx_productLoseFormID->EnableWindow(false);
tx_storeHouseLose=GetDlgItem(IDC_storeHouseLose);
tx_houseOutType=GetDlgItem(IDC_houseOutType);
tx_formDate=GetDlgItem(IDC_formDate);
tx_remark=GetDlgItem(IDC_remark);
tx_dealer=GetDlgItem(IDC_dealer);
_RecordsetPtr m_pRecordset;
HRESULT hTRes;
CString strSQL;
strSQL="select distinct staffName from staff";
hTRes = m_pRecordset.CreateInstance(_T("ADODB.Recordset"));
if (SUCCEEDED(hTRes))
{
//----------------------------------------------------
hTRes = m_pRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
((CStoreApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
adOpenDynamic,adLockPessimistic,adCmdText);
if(SUCCEEDED(hTRes))
{
while(!(m_pRecordset->adoEOF))
{
m_dealerCombo.AddString(((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("staffName")));
m_pRecordset->MoveNext();
}
}
}
m_pRecordset->Close();
strSQL="select distinct houseOutTypeName from houseOutType";
hTRes = m_pRecordset.CreateInstance(_T("ADODB.Recordset"));
if (SUCCEEDED(hTRes))
{
//----------------------------------------------------
hTRes = m_pRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
((CStoreApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
adOpenDynamic,adLockPessimistic,adCmdText);
if(SUCCEEDED(hTRes))
{
while(!(m_pRecordset->adoEOF))
{
m_houseOutTypeCombo.AddString(((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("houseOutTypeName")));
m_pRecordset->MoveNext();
}
}
}
m_pRecordset->Close();
strSQL="select distinct storeHouseName from storeHouse";
hTRes = m_pRecordset.CreateInstance(_T("ADODB.Recordset"));
if (SUCCEEDED(hTRes))
{
//----------------------------------------------------
hTRes = m_pRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
((CStoreApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
adOpenDynamic,adLockPessimistic,adCmdText);
if(SUCCEEDED(hTRes))
{
while(!(m_pRecordset->adoEOF))
{
m_storeHouseLoseCombo.AddString(((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("storeHouseName")));
m_pRecordset->MoveNext();
}
}
}
m_pRecordset->Close();
if(is_search==1)
{
bt_add->EnableWindow(true);
bt_delete->EnableWindow(true);
bt_modify->EnableWindow(true);
bt_addLine->EnableWindow(false);
bt_deleteLine->EnableWindow(false);
bt_save->EnableWindow(false);
bt_cancelation->EnableWindow(false);
CString strSQL;
_RecordsetPtr m_pRecordset; //用于创建一个查询记录集
_RecordsetPtr m_pProductLoseFormRecordset;
strSQL="select * from productLoseForm where productLoseFormID='";
strSQL=strSQL+m_productLoseFormID+"'";
HRESULT hTRes;
hTRes = m_pProductLoseFormRecordset.CreateInstance(_T("ADODB.Recordset"));
hTRes = m_pProductLoseFormRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
((CStoreApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
adOpenDynamic,adLockPessimistic,adCmdText);
if(!(m_pProductLoseFormRecordset->adoEOF))
{
DATE dt;
COleDateTime da;
dt=m_pProductLoseFormRecordset->GetCollect("formDate").date;
da=COleDateTime(dt);
m_formDate.SetDate(da.GetYear(),da.GetMonth(),da.GetDay());
m_storeHouseLose = ((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pProductLoseFormRecordset->GetCollect("storeHouse"));
m_houseOutType = ((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pProductLoseFormRecordset->GetCollect("houseOutType"));
m_dealer = ((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pProductLoseFormRecordset->GetCollect("dealer"));
m_remark = ((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pProductLoseFormRecordset->GetCollect("remark"));
strSQL="select * from productLoseFormView where productLoseFormID='";
strSQL=strSQL+m_productLoseFormID+"'";
hTRes = m_pRecordset.CreateInstance(_T("ADODB.Recordset"));
hTRes = m_pRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
((CStoreApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
adOpenDynamic,adLockPessimistic,adCmdText);
int i=0;
while(!(m_pRecordset->adoEOF))
{
m_list.InsertItem(i,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("productID")));
m_list.SetItemText(i,1,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("productName")));
m_list.SetItemText(i,2,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("unit")));
m_list.SetItemText(i,3,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("model")));
m_list.SetItemText(i,4,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("num")));
m_list.SetItemText(i,5,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("price")));
m_list.SetItemText(i,6,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("total")));
i++;
m_pRecordset->MoveNext();
}
}
tx_storeHouseLose->EnableWindow(false);
tx_houseOutType->EnableWindow(false);
tx_formDate->EnableWindow(false);
tx_remark->EnableWindow(false);
}
else
{
bt_add->EnableWindow(false);
bt_delete->EnableWindow(false);
bt_modify->EnableWindow(false);
bt_addLine->EnableWindow(true);
bt_deleteLine->EnableWindow(true);
bt_save->EnableWindow(true);
bt_cancelation->EnableWindow(true);
tx_storeHouseLose->EnableWindow(true);
tx_houseOutType->EnableWindow(true);
tx_formDate->EnableWindow(true);
tx_remark->EnableWindow(true);
int formID=((CStoreApp*)AfxGetApp())->m_pIDRecordset->GetCollect("productLoseFormID").intVal;
if(formID<10)
m_productLoseFormID.Format("CPBS0000%d",formID);
else if(formID<100&&formID>9)
m_productLoseFormID.Format("CPBS000%d",formID);
else if(formID<1000&&formID>99)
m_productLoseFormID.Format("CPBS00%d",formID);
CString str;
str.Format("%d",formID+1);
((CStoreApp*)AfxGetApp())->m_pIDRecordset->PutCollect("productLoseFormID",_variant_t(str));
((CStoreApp*)AfxGetApp())->m_pIDRecordset->Update();
}
UpdateData(false);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CProductLoseForm::OnClickList(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
*pResult = 0;
}
void CProductLoseForm::OnAdd()
{
flag=1;
bt_add->EnableWindow(false);
bt_delete->EnableWindow(false);
bt_save->EnableWindow(true);
bt_modify->EnableWindow(false);
bt_addLine->EnableWindow(true);
bt_deleteLine->EnableWindow(true);
bt_cancelation->EnableWindow(true);
tx_storeHouseLose->EnableWindow(true);
tx_houseOutType->EnableWindow(true);
tx_formDate->EnableWindow(true);
tx_remark->EnableWindow(true);
tx_dealer->EnableWindow(true);
int formID=((CStoreApp*)AfxGetApp())->m_pIDRecordset->GetCollect("productLoseFormID").intVal;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -