📄 salecontract.cpp
字号:
// SaleContract.cpp : implementation file
//
#include "stdafx.h"
#include "Sale.h"
#include "SaleContract.h"
#include "SelectCommodityForQuote.h"
#include "Affirm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSaleContract dialog
CSaleContract::CSaleContract(CWnd* pParent /*=NULL*/)
: CDialog(CSaleContract::IDD, pParent)
{
//{{AFX_DATA_INIT(CSaleContract)
m_planID = _T("");
m_formDate = COleDateTime::GetCurrentTime();
m_saleType = _T("");
m_department = _T("");
m_clientName = _T("");
m_contractType = _T("");
m_seller = _T("");
m_companyContractPerson = _T("");
m_transportType = _T("");
m_consignmentAddress = _T("");
m_clientContractPerson = _T("");
m_payCondition = _T("");
m_subscription = 0.0f;
m_contractEndDate = COleDateTime::GetCurrentTime();;
m_remark = _T("");
m_contractID = _T("");
contractID = _T("");
//}}AFX_DATA_INIT
}
void CSaleContract::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSaleContract)
DDX_Control(pDX, IDC_payCondition, m_payConditionCombo);
DDX_Control(pDX, IDC_transportType, m_transportTypeCombo);
DDX_Control(pDX, IDC_seller, m_sellorCombo);
DDX_Control(pDX, IDC_contractType, m_contractTypeCombo);
DDX_Control(pDX, IDC_clientName, m_clientCombo);
DDX_Control(pDX, IDC_department, m_departmentCombo);
DDX_Control(pDX, IDC_saleType, m_saleTypeCombo);
DDX_Control(pDX, IDC_planID, m_planIDCombo);
DDX_Control(pDX, IDC_LIST1, m_contractList);
DDX_CBString(pDX, IDC_planID, m_planID);
DDX_DateTimeCtrl(pDX, IDC_formDate, m_formDate);
DDX_CBString(pDX, IDC_saleType, m_saleType);
DDX_CBString(pDX, IDC_department, m_department);
DDX_CBString(pDX, IDC_clientName, m_clientName);
DDX_CBString(pDX, IDC_contractType, m_contractType);
DDX_CBString(pDX, IDC_seller, m_seller);
DDX_Text(pDX, IDC_companyContractPerson, m_companyContractPerson);
DDX_CBString(pDX, IDC_transportType, m_transportType);
DDX_Text(pDX, IDC_consignmentAddress, m_consignmentAddress);
DDX_Text(pDX, IDC_clientContractPerson, m_clientContractPerson);
DDX_CBString(pDX, IDC_payCondition, m_payCondition);
DDX_Text(pDX, IDC_subscription, m_subscription);
DDX_DateTimeCtrl(pDX, IDC_formDate2, m_contractEndDate);
DDX_Text(pDX, IDC_remark, m_remark);
DDX_Text(pDX, IDC_contractID, m_contractID);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSaleContract, CDialog)
//{{AFX_MSG_MAP(CSaleContract)
ON_BN_CLICKED(IDC_firstPage, OnFirstPage)
ON_BN_CLICKED(IDC_prevPage, OnPrevPage)
ON_BN_CLICKED(IDC_nextPage, OnNextPage)
ON_BN_CLICKED(IDC_lastPage, OnLastPage)
ON_BN_CLICKED(IDC_new, OnNew)
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_exit, OnExit)
ON_NOTIFY(NM_CLICK, IDC_LIST1, OnClickContractList)
ON_CBN_KILLFOCUS(IDC_planID, OnKillfocusQuoteID)
ON_BN_CLICKED(IDC_auditing, Onauditing)
ON_BN_CLICKED(IDC_cancellation, OnCancellation)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSaleContract message handlers
BOOL CSaleContract::OnInitDialog()
{
CDialog::OnInitDialog();
UpdateData(true);
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_cancellaion=GetDlgItem(IDC_cancellation);
DWORD style;
style=m_contractList.GetExStyle();
style=(style|LVS_EX_GRIDLINES|LVS_EX_FULLROWSELECT)&(~LVS_EX_CHECKBOXES) ;
m_contractList.SetExtendedStyle(style);
m_contractList.InsertColumn(0,"产品编号",LVCFMT_LEFT,100);
m_contractList.InsertColumn(1,"产品名称",LVCFMT_LEFT,100);
m_contractList.InsertColumn(2,"参考价格",LVCFMT_LEFT,100);
m_contractList.InsertColumn(3,"数量",LVCFMT_LEFT,100);
m_contractList.InsertColumn(4,"单价",LVCFMT_LEFT,100);
CString strSQL;
HRESULT hTRes;
_RecordsetPtr m_pRecordset; //用于创建一个查询记录集
//-----------------------------------------------
strSQL="SELECT * FROM saleContract";
try
{
hTRes = m_psaleContractRecordset.CreateInstance(_T("ADODB.Recordset"));
if (SUCCEEDED(hTRes))
{
//----------------------------------------------------
hTRes = m_psaleContractRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
((CSaleApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
adOpenDynamic,adLockPessimistic,adCmdText);
if(SUCCEEDED(hTRes))
{
TRACE(_T("连接成功!\n"));
// AfxMessageBox(contractID);
if(contractID!="")
{
while(!(m_psaleContractRecordset->adoEOF))
{
CString str2=((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_psaleContractRecordset->GetCollect("contractID"));
if(((CSaleApp*)AfxGetApp())->compareTwoCString(contractID,str2)==0)
break;
else
m_psaleContractRecordset->MoveNext();
}
}
if (!(m_psaleContractRecordset->adoEOF))
{
m_planID=((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_psaleContractRecordset->GetCollect("quoteID"));
m_contractID = ((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_psaleContractRecordset->GetCollect("contractID"));
DATE dt;
COleDateTime da;
dt=m_psaleContractRecordset->GetCollect("formDate").date;
da=COleDateTime(dt);
m_formDate.SetDate(da.GetYear(),da.GetMonth(),da.GetDay());
m_saleType=((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_psaleContractRecordset->GetCollect("saleType"));
m_department=((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_psaleContractRecordset->GetCollect("department"));
m_contractType=((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_psaleContractRecordset->GetCollect("contractType"));
m_seller =((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_psaleContractRecordset->GetCollect("sellor"));
m_companyContractPerson=((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_psaleContractRecordset->GetCollect("companyContractPerson"));
m_transportType=((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_psaleContractRecordset->GetCollect("transportType"));
m_consignmentAddress=((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_psaleContractRecordset->GetCollect("consignmentAddress"));
m_clientContractPerson=((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_psaleContractRecordset->GetCollect("clientContractPerson"));
m_payCondition=((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_psaleContractRecordset->GetCollect("payCondition"));
m_subscription=atof(((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_psaleContractRecordset->GetCollect("subscription")));
dt=m_psaleContractRecordset->GetCollect("contractEndDate").date;
da=COleDateTime(dt);
m_contractEndDate.SetDate(da.GetYear(),da.GetMonth(),da.GetDay());
m_clientName=((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_psaleContractRecordset->GetCollect("clientName"));
CString checked;
checked=((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_psaleContractRecordset->GetCollect("checked"));
if(checked=="T")
{
SetDlgItemText(IDC_auditing,"弃审");
bt_modify->EnableWindow(false);
}
else
{
SetDlgItemText(IDC_auditing,"审核");
bt_modify->EnableWindow(true);
}
strSQL="select * from saleContractView where contractID='";
strSQL=strSQL+((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_psaleContractRecordset->GetCollect("contractID"));
strSQL+="'";
}
//---------------------------------------
hTRes = m_pRecordset.CreateInstance(_T("ADODB.Recordset"));
hTRes = m_pRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
((CSaleApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
adOpenDynamic,adLockPessimistic,adCmdText);
int i=0;
while(!(m_pRecordset->adoEOF))
{
m_contractList.InsertItem(i,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("commidityID")));
m_contractList.SetItemText(i,1,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("commodityName")));
m_contractList.SetItemText(i,2,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("standardPrice")));
m_contractList.SetItemText(i,3,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("num")));
m_contractList.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_planID=GetDlgItem(IDC_planID);
tx_formDate=GetDlgItem(IDC_formDate);
tx_saleType=GetDlgItem(IDC_saleType);
tx_department=GetDlgItem(IDC_department);
tx_clientName=GetDlgItem(IDC_clientName);
tx_contractType=GetDlgItem(IDC_contractType);
tx_seller=GetDlgItem(IDC_seller);
tx_companyContractPerson=GetDlgItem(IDC_companyContractPerson);
tx_transportType=GetDlgItem(IDC_transportType);
tx_consignmentAddress=GetDlgItem(IDC_consignmentAddress);
tx_clientContractPerson=GetDlgItem(IDC_clientContractPerson);
tx_payCondition=GetDlgItem(IDC_payCondition);
tx_subscription=GetDlgItem(IDC_subscription);
tx_contractEndDate=GetDlgItem(IDC_formDate2);
tx_remark=GetDlgItem(IDC_remark);
tx_contractID=GetDlgItem(IDC_contractID);
tx_planID->EnableWindow(false);
tx_formDate->EnableWindow(false);
tx_saleType->EnableWindow(false);
tx_department->EnableWindow(false);
tx_clientName->EnableWindow(false);
tx_contractType->EnableWindow(false);
tx_seller->EnableWindow(false);
tx_companyContractPerson->EnableWindow(false);
tx_transportType->EnableWindow(false);
tx_consignmentAddress->EnableWindow(false);
tx_clientContractPerson->EnableWindow(false);
tx_payCondition->EnableWindow(false);
tx_subscription->EnableWindow(false);
tx_contractEndDate->EnableWindow(false);
tx_remark->EnableWindow(false);
tx_contractID->EnableWindow(false);
bt_firstPage->EnableWindow(false);
bt_prevPage->EnableWindow(false);
// bt_nextPage->EnableWindow(false);
// bt_lastPage->EnableWindow(false);
// bt_add->EnableWindow(false);
bt_save->EnableWindow(false);
// bt_modify->EnableWindow(false);
// bt_delete->EnableWindow(false);
bt_addLine->EnableWindow(false);
bt_deleteLine->EnableWindow(false);
bt_cancellaion->EnableWindow(false);
UpdateData(false);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CSaleContract::OnFirstPage()
{
UpdateData(true);
_RecordsetPtr m_pRecordset;
CString strSQL;
HRESULT hTRes;
m_psaleContractRecordset->MoveFirst();
if (!(m_psaleContractRecordset->adoEOF))
{
m_planID=((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_psaleContractRecordset->GetCollect("quoteID"));
m_contractID = ((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_psaleContractRecordset->GetCollect("contractID"));
DATE dt;
COleDateTime da;
dt=m_psaleContractRecordset->GetCollect("formDate").date;
da=COleDateTime(dt);
m_formDate.SetDate(da.GetYear(),da.GetMonth(),da.GetDay());
m_saleType=((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_psaleContractRecordset->GetCollect("saleType"));
m_department=((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_psaleContractRecordset->GetCollect("department"));
m_contractType=((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_psaleContractRecordset->GetCollect("contractType"));
m_seller =((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_psaleContractRecordset->GetCollect("sellor"));
m_companyContractPerson=((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_psaleContractRecordset->GetCollect("companyContractPerson"));
m_transportType=((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_psaleContractRecordset->GetCollect("transportType"));
m_consignmentAddress=((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_psaleContractRecordset->GetCollect("consignmentAddress"));
m_clientContractPerson=((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_psaleContractRecordset->GetCollect("clientContractPerson"));
m_payCondition=((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_psaleContractRecordset->GetCollect("payCondition"));
m_subscription=atof(((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_psaleContractRecordset->GetCollect("subscription")));
dt=m_psaleContractRecordset->GetCollect("contractEndDate").date;
da=COleDateTime(dt);
m_contractEndDate.SetDate(da.GetYear(),da.GetMonth(),da.GetDay());
m_clientName=((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_psaleContractRecordset->GetCollect("clientName"));
CString checked;
checked=((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_psaleContractRecordset->GetCollect("checked"));
if(checked=="T")
{
SetDlgItemText(IDC_auditing,"弃审");
bt_modify->EnableWindow(false);
}
else
{
SetDlgItemText(IDC_auditing,"审核");
bt_modify->EnableWindow(true);
}
strSQL="select * from saleContractView where contractID='";
strSQL=strSQL+((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_psaleContractRecordset->GetCollect("contractID"));
strSQL+="'";
}
//---------------------------------------
hTRes = m_pRecordset.CreateInstance(_T("ADODB.Recordset"));
hTRes = m_pRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
((CSaleApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
adOpenDynamic,adLockPessimistic,adCmdText);
int i=0;
m_contractList.DeleteAllItems();
while(!(m_pRecordset->adoEOF))
{
m_contractList.InsertItem(i,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("commidityID")));
m_contractList.SetItemText(i,1,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("commodityName")));
m_contractList.SetItemText(i,2,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("standardPrice")));
m_contractList.SetItemText(i,3,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("num")));
m_contractList.SetItemText(i,4,((CSaleApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("truePrice")));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -