📄 consignmentinvoice.cpp
字号:
m_department = ((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pConsignmentFormRecordset->GetCollect("department"));
m_consignmentAddress = ((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pConsignmentFormRecordset->GetCollect("consignmentAddress"));
m_storeHouse = ((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pConsignmentFormRecordset->GetCollect("storeHouse"));
m_remark = ((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pConsignmentFormRecordset->GetCollect("remark"));
CString checked;
checked=((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pConsignmentFormRecordset->GetCollect("checked"));
if(checked=="T")
{
SetDlgItemText(IDC_auditing,"弃审");
bt_modify->EnableWindow(false);
}
else
{
bt_modify->EnableWindow(true);
SetDlgItemText(IDC_auditing,"审核");
}
strSQL="select * from consignmentFormView1 where consignmentFormID='";
strSQL=strSQL+((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pConsignmentFormRecordset->GetCollect("consignmentFormID"));
strSQL+="'";
}
//---------------------------------------
hTRes = m_pRecordset.CreateInstance(_T("ADODB.Recordset"));
hTRes = m_pRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
((CSaleApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
adOpenDynamic,adLockPessimistic,adCmdText);
// m_pRecordset->MoveFirst();
int i=0;
m_consignmentFormList.DeleteAllItems();
while(!(m_pRecordset->adoEOF))
{
m_consignmentFormList.InsertItem(i,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("commidityID")));
m_consignmentFormList.SetItemText(i,1,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("commodityName")));
m_consignmentFormList.SetItemText(i,2,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("standardPrice")));
m_consignmentFormList.SetItemText(i,3,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("num")));
m_consignmentFormList.SetItemText(i,4,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("truePrice")));
if (!(m_pRecordset->adoEOF))
{
m_pRecordset->MoveNext();
i++;
}
}
bt_nextPage->EnableWindow(true);
bt_lastPage->EnableWindow(true);
bt_firstPage->EnableWindow(false);
bt_prevPage->EnableWindow(false);
UpdateData(false);
}
void CConsignmentInvoice::OnClickConsignmenFormList(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
*pResult = 0;
}
BOOL CConsignmentInvoice::OnInitDialog()
{
CDialog::OnInitDialog();
bt_firstPage=GetDlgItem(IDC_firstPage);
bt_prevPage=GetDlgItem(IDC_prevPage);
bt_nextPage=GetDlgItem(IDC_nextPage);
bt_lastPage=GetDlgItem(IDC_lastPage);
bt_add=GetDlgItem(IDC_new);
bt_save=GetDlgItem(IDC_save);
bt_modify=GetDlgItem(IDC_modify);
bt_delete=GetDlgItem(IDC_delete);
bt_addLine=GetDlgItem(IDC_addLine);
bt_deleteLine=GetDlgItem(IDC_deleteLine);
bt_checked=GetDlgItem(IDC_auditing);
bt_cancellation=GetDlgItem(IDC_cancellation);
bt_cancellation->EnableWindow(false);
DWORD style;
style=m_consignmentFormList.GetExStyle();
style=(style|LVS_EX_GRIDLINES|LVS_EX_FULLROWSELECT)&(~LVS_EX_CHECKBOXES) ;
m_consignmentFormList.SetExtendedStyle(style);
m_consignmentFormList.InsertColumn(0,"产品编号",LVCFMT_LEFT,100);
m_consignmentFormList.InsertColumn(1,"产品名称",LVCFMT_LEFT,100);
m_consignmentFormList.InsertColumn(2,"参考价格",LVCFMT_LEFT,100);
m_consignmentFormList.InsertColumn(3,"数量",LVCFMT_LEFT,100);
m_consignmentFormList.InsertColumn(4,"单价",LVCFMT_LEFT,100);
CString strSQL;
HRESULT hTRes;
_RecordsetPtr m_pRecordset; //用于创建一个查询记录集
strSQL="SELECT * FROM consignmentForm";
try
{
hTRes = m_pConsignmentFormRecordset.CreateInstance(_T("ADODB.Recordset"));
if (SUCCEEDED(hTRes))
{
hTRes = m_pConsignmentFormRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
((CSaleApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
adOpenDynamic,adLockPessimistic,adCmdText);
if(SUCCEEDED(hTRes))
{
TRACE(_T("连接成功!\n"));
if(consignmentFormID!="")
{
while(!(m_pConsignmentFormRecordset->adoEOF))
{
CString str2=((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pConsignmentFormRecordset->GetCollect("consignmentFormID"));
if(((CSaleApp*)AfxGetApp())->compareTwoCString(consignmentFormID,str2)==0)
break;
else
m_pConsignmentFormRecordset->MoveNext();
}
}
if (!(m_pConsignmentFormRecordset->adoEOF))
{
m_consignmentFormID = ((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pConsignmentFormRecordset->GetCollect("consignmentFormID"));
m_orderFormID = ((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pConsignmentFormRecordset->GetCollect("orderFormID"));
DATE dt;
COleDateTime da;
dt=m_pConsignmentFormRecordset->GetCollect("formDate").date;
da=COleDateTime(dt);
m_formDate.SetDate(da.GetYear(),da.GetMonth(),da.GetDay());
m_transportType = ((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pConsignmentFormRecordset->GetCollect("transportType"));
m_transportCompany = ((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pConsignmentFormRecordset->GetCollect("transportCompany"));
m_clientName = ((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pConsignmentFormRecordset->GetCollect("clientName"));
m_payCondition = ((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pConsignmentFormRecordset->GetCollect("payCondition"));
m_seller = ((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pConsignmentFormRecordset->GetCollect("seller"));
m_saleType = ((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pConsignmentFormRecordset->GetCollect("saleType"));
m_department = ((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pConsignmentFormRecordset->GetCollect("department"));
m_consignmentAddress = ((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pConsignmentFormRecordset->GetCollect("consignmentAddress"));
m_storeHouse = ((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pConsignmentFormRecordset->GetCollect("storeHouse"));
m_remark = ((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pConsignmentFormRecordset->GetCollect("remark"));
CString checked;
checked=((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pConsignmentFormRecordset->GetCollect("checked"));
if(checked=="T")
{
SetDlgItemText(IDC_auditing,"弃审");
bt_modify->EnableWindow(false);
}
else
{
bt_modify->EnableWindow(true);
SetDlgItemText(IDC_auditing,"审核");
}
strSQL="select * from consignmentFormView1 where consignmentFormID='";
strSQL=strSQL+((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pConsignmentFormRecordset->GetCollect("consignmentFormID"));
strSQL+="'";
}
hTRes = m_pRecordset.CreateInstance(_T("ADODB.Recordset"));
hTRes = m_pRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
((CSaleApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
adOpenDynamic,adLockPessimistic,adCmdText);
m_consignmentFormList.DeleteAllItems();
int i=0;
while(!(m_pRecordset->adoEOF))
{
m_consignmentFormList.InsertItem(i,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("commidityID")));
m_consignmentFormList.SetItemText(i,1,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("commodityName")));
m_consignmentFormList.SetItemText(i,2,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("standardPrice")));
m_consignmentFormList.SetItemText(i,3,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("num")));
m_consignmentFormList.SetItemText(i,4,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("truePrice")));
if (!(m_pRecordset->adoEOF))
{
m_pRecordset->MoveNext();
i++;
}
}
}
}
}
catch(_com_error e)///捕捉异常
{
CString errormessage;
MessageBox("创建记录集失败!","错误");
}
flag=0;
tx_consignmentFormID=GetDlgItem(IDC_consignmentFormID);
tx_orderFormID=GetDlgItem(IDC_orderFormID);
tx_formDate=GetDlgItem(IDC_formDate);
tx_transportType=GetDlgItem(IDC_transportType);
tx_transportCompany=GetDlgItem(IDC_transportCompany);
tx_clientName=GetDlgItem(IDC_clientName);
tx_payCondition=GetDlgItem(IDC_payCondition);
tx_seller=GetDlgItem(IDC_seller);
tx_saleType=GetDlgItem(IDC_saleType);
tx_department=GetDlgItem(IDC_department);
tx_consignmentAddress=GetDlgItem(IDC_consignmentAddress);
tx_storeHouse=GetDlgItem(IDC_storeHouse);
tx_remark=GetDlgItem(IDC_remark);
tx_consignmentFormID->EnableWindow(false);
tx_orderFormID->EnableWindow(false);
tx_formDate->EnableWindow(false);
tx_transportType->EnableWindow(false);
tx_transportCompany->EnableWindow(false);
tx_clientName->EnableWindow(false);
tx_payCondition->EnableWindow(false);
tx_seller->EnableWindow(false);
tx_saleType->EnableWindow(false);
tx_department->EnableWindow(false);
tx_consignmentAddress->EnableWindow(false);
tx_storeHouse->EnableWindow(false);
tx_remark->EnableWindow(false);
UpdateData(false);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CConsignmentInvoice::OnKillfocusOrderFormID()
{
CString strSQL;
HRESULT hTRes;
UpdateData(true);
_RecordsetPtr m_pOrderFormRecordset;
_RecordsetPtr m_pRecordset; //用于创建一个查询记录集
strSQL="SELECT * FROM orderForm where orderFormID='";
strSQL=strSQL+m_orderFormID+"'";
try
{
hTRes = m_pOrderFormRecordset.CreateInstance(_T("ADODB.Recordset"));
if (SUCCEEDED(hTRes))
{
hTRes = m_pOrderFormRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
((CSaleApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
adOpenDynamic,adLockPessimistic,adCmdText);
if(SUCCEEDED(hTRes))
{
TRACE(_T("连接成功!\n"));
// m_pQuoteRecordset->MoveFirst();
if (!(m_pOrderFormRecordset->adoEOF))
{
m_clientName = ((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pOrderFormRecordset->GetCollect("clientName"));
m_transportType=((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pOrderFormRecordset->GetCollect("transportType"));
m_payCondition=((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pOrderFormRecordset->GetCollect("payCondition"));
m_seller =((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pOrderFormRecordset->GetCollect("seller"));
m_department = ((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pOrderFormRecordset->GetCollect("department"));
m_consignmentAddress = ((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pOrderFormRecordset->GetCollect("consignmentAddress"));
m_saleType = ((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pOrderFormRecordset->GetCollect("saleType"));
strSQL="select * from orderFormView where orderFormID='";
strSQL=strSQL+((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pOrderFormRecordset->GetCollect("orderFormID"));
strSQL+="'";
}
else
{
return;
}
hTRes = m_pRecordset.CreateInstance(_T("ADODB.Recordset"));
hTRes = m_pRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
((CSaleApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
adOpenDynamic,adLockPessimistic,adCmdText);
m_consignmentFormList.DeleteAllItems();
int i=0;
while(!(m_pRecordset->adoEOF))
{
m_consignmentFormList.InsertItem(i,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("commidityID")));
m_consignmentFormList.SetItemText(i,1,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("commodityName")));
m_consignmentFormList.SetItemText(i,2,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("standardPrice")));
m_consignmentFormList.SetItemText(i,3,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("num")));
m_consignmentFormList.SetItemText(i,4,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("truePrice")));
if (!(m_pRecordset->adoEOF))
{
m_pRecordset->MoveNext();
i++;
}
}
}
}
}
catch(_com_error e)///捕捉异常
{
CString errormessage;
MessageBox("创建记录集失败!","错误");
}
UpdateData(false);
}
void CConsignmentInvoice::OnAuditing()
{
CString str;
GetDlgItemText(IDC_auditing,str);
if(str=="审核")
{
m_pConsignmentFormRecordset->PutCollect("checked",_variant_t("T"));
m_pConsignmentFormRecordset->Update();
AfxMessageBox("通过审核!");
bt_modify->EnableWindow(false);
if(m_pConsignmentFormRecordset->adoEOF)
m_pConsignmentFormRecordset->MovePrevious();
SetDlgItemText(IDC_auditing,"弃审");
}
else
{
_RecordsetPtr m_pCheckRecordset;
if(m_pConsignmentFormRecordset->adoEOF)
m_pConsignmentFormRecordset->MovePrevious();
CString strSQL;
strSQL="SELECT * FROM consignmentFormCommidity where consignmentFormID='";
strSQL=strSQL+m_consignmentFormID+"' and invoiced='T'";
{
HRESULT hTRes;
hTRes = m_pCheckRecordset.CreateInstance(_T("ADODB.Recordset"));
if (SUCCEEDED(hTRes))
{
hTRes = m_pCheckRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
((CSaleApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
adOpenDynamic,adLockPessimistic,adCmdText);
if(SUCCEEDED(hTRes))
{
if(m_pCheckRecordset->RecordCount!=0)
{
AfxMessageBox("该发货单已经开完发票,不可以弃审!!!");
return;
}
}
}
}
m_pConsignmentFormRecordset->PutCollect("checked",_variant_t("F"));
m_pConsignmentFormRecordset->Update();
AfxMessageBox("审核取消!");
bt_modify->EnableWindow(true);
SetDlgItemText(IDC_auditing,"审核");
}
}
void CConsignmentInvoice::OnCancellation()
{
int consignmentFormID=((CSaleApp*)AfxGetApp())->m_pIDRecordset->GetCollect("consignmentFormID").intVal;
CString str;
str.Format("%d",consignmentFormID+1);
((CSaleApp*)AfxGetApp())->m_pIDRecordset->PutCollect("consignmentFormID",_variant_t(str));
((CSaleApp*)AfxGetApp())->m_pIDRecordset->Update();
bt_cancellation->EnableWindow(false);
OnNextPage();
bt_checked->EnableWindow(true);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -