📄 materialmoveform.cpp
字号:
}
else if(flag==2) //修改
{
_variant_t RecordsAffected;
CString strSQL;
strSQL="delete from materialMoveFormCommidity where materialMoveFormID='";
strSQL=strSQL+m_materialMoveFormID+"'";
(((CStoreApp*)AfxGetApp())->m_pConn)->Execute((_bstr_t)strSQL,&RecordsAffected,adCmdText);
m_pMaterialMoveFormRecordset->Update();
strSQL="SELECT * FROM materialMoveFormCommidity" ;
try
{
HRESULT hTRes;
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))
{
TRACE(_T("连接成功!\n"));
for(int i=0;i<m_list.GetItemCount();i++)
{
m_pRecordset->AddNew();
m_pRecordset->PutCollect("materialMoveFormID",_variant_t(m_materialMoveFormID.Left(25)));
m_pRecordset->PutCollect("materialID",_variant_t(m_list.GetItemText(i,0).Left(25)));
m_pRecordset->PutCollect("num",_variant_t(m_list.GetItemText(i,4)));
m_pRecordset->PutCollect("price",_variant_t(m_list.GetItemText(i,5)));
m_pRecordset->Update();
}
AfxMessageBox("保存成功!");
}
}
}
catch(_com_error e)///捕捉异常
{
CString errormessage;
MessageBox("创建记录集失败!","错误");
}
}
bt_add->EnableWindow(true);
bt_modify->EnableWindow(true);
bt_delete->EnableWindow(true);
bt_save->EnableWindow(false);
bt_addLine->EnableWindow(false);
bt_deleteLine->EnableWindow(false);
bt_cancelation->EnableWindow(false);
tx_storeHouseIn->EnableWindow(false);
tx_storeHouseOut->EnableWindow(false);
tx_dealer->EnableWindow(false);
tx_houseOutType->EnableWindow(false);
tx_FormDate->EnableWindow(false);
tx_remark->EnableWindow(false);
UpdateData(false);
}
void CMaterialMoveForm::OnCancelation()
{
int formID=((CStoreApp*)AfxGetApp())->m_pIDRecordset->GetCollect("materialMoveFormID").intVal;
formID-=1;
CString str;
str.Format("%d",formID);
((CStoreApp*)AfxGetApp())->m_pIDRecordset->PutCollect("materialMoveFormID",(_variant_t)str);
((CStoreApp*)AfxGetApp())->m_pIDRecordset->Update();
bt_cancelation->EnableWindow(false);
bt_add->EnableWindow(true);
bt_delete->EnableWindow(false);
bt_modify->EnableWindow(false);
bt_deleteLine->EnableWindow(false);
bt_addLine->EnableWindow(false);
bt_save->EnableWindow(false);
m_materialMoveFormID="";
tx_storeHouseIn->EnableWindow(false);
tx_storeHouseOut->EnableWindow(false);
tx_dealer->EnableWindow(false);
tx_houseOutType->EnableWindow(false);
tx_FormDate->EnableWindow(false);
tx_remark->EnableWindow(false);
UpdateData(false);
}
BOOL CMaterialMoveForm::OnInitDialog()
{
CDialog::OnInitDialog();
CWnd* tx_materialMoveFormID;
tx_materialMoveFormID=GetDlgItem(IDC_materialMoveFormID);
tx_materialMoveFormID->EnableWindow(false);
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_modify1);
bt_addLine=GetDlgItem(IDC_addLine);
bt_deleteLine=GetDlgItem(IDC_deleteLine);
bt_save=GetDlgItem(IDC_save);
bt_cancelation=GetDlgItem(IDC_cancelation);
tx_materialMoveFormID=GetDlgItem(IDC_materialMoveFormID);
tx_storeHouseIn=GetDlgItem(IDC_storehouseIn);
tx_storeHouseOut=GetDlgItem(IDC_storehouseOut);
tx_dealer=GetDlgItem(IDC_dealer);
tx_houseOutType=GetDlgItem(IDC_houseOutType);
tx_FormDate=GetDlgItem(IDC_formDate);
tx_remark=GetDlgItem(IDC_remark);
_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_storeHouseInCombo.AddString(((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("storeHouseName")));
m_storeHouseOutCombo.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_pMaterialMoveFormRecordset;
strSQL="select * from materialMoveForm where materialMoveFormID='";
strSQL=strSQL+m_materialMoveFormID+"'";
HRESULT hTRes;
hTRes = m_pMaterialMoveFormRecordset.CreateInstance(_T("ADODB.Recordset"));
hTRes = m_pMaterialMoveFormRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
((CStoreApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
adOpenDynamic,adLockPessimistic,adCmdText);
if(!(m_pMaterialMoveFormRecordset->adoEOF))
{
DATE dt;
COleDateTime da;
dt=m_pMaterialMoveFormRecordset->GetCollect("formDate").date;
da=COleDateTime(dt);
m_FormDate.SetDate(da.GetYear(),da.GetMonth(),da.GetDay());
m_storeHouseIn = ((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pMaterialMoveFormRecordset->GetCollect("storeHouseIn"));
m_storeHouseOut = ((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pMaterialMoveFormRecordset->GetCollect("storeHouseOut"));
m_dealer = ((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pMaterialMoveFormRecordset->GetCollect("dealer"));
m_houseOutType = ((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pMaterialMoveFormRecordset->GetCollect("houseOutType"));
m_remark = ((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pMaterialMoveFormRecordset->GetCollect("remark"));
strSQL="select * from materialMoveFormView where materialMoveFormID='";
strSQL=strSQL+m_materialMoveFormID+"'";
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("materialID")));
m_list.SetItemText(i,1,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("materialName")));
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_storeHouseIn->EnableWindow(false);
tx_storeHouseOut->EnableWindow(false);
tx_dealer->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_storeHouseIn->EnableWindow(true);
tx_storeHouseOut->EnableWindow(true);
tx_dealer->EnableWindow(true);
tx_houseOutType->EnableWindow(true);
tx_FormDate->EnableWindow(true);
tx_remark->EnableWindow(true);
int formID=((CStoreApp*)AfxGetApp())->m_pIDRecordset->GetCollect("materialMoveFormID").intVal;
if(formID<10)
m_materialMoveFormID.Format("CLDB0000%d",formID);
else if(formID<100&&formID>9)
m_materialMoveFormID.Format("CLDB000%d",formID);
else if(formID<1000&&formID>99)
m_materialMoveFormID.Format("CLDB00%d",formID);
CString str;
str.Format("%d",formID+1);
((CStoreApp*)AfxGetApp())->m_pIDRecordset->PutCollect("materialMoveFormID",_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
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -