📄 clientproductform.cpp
字号:
// ClientProductForm.cpp : implementation file
//
#include "stdafx.h"
#include "ClientRelationship.h"
#include "ClientProductForm.h"
#include "ClientProduct.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CClientProductForm dialog
CClientProductForm::CClientProductForm(CWnd* pParent /*=NULL*/)
: CDialog(CClientProductForm::IDD, pParent)
{
//{{AFX_DATA_INIT(CClientProductForm)
m_beginDate = COleDateTime::GetCurrentTime();
m_endDate = COleDateTime::GetCurrentTime();
m_productID = _T("");
m_productName = _T("");
m_standard = _T("");
m_price = 0.0f;
m_num = 0;
m_unit = _T("");
m_total = 0.0f;
m_manageRange = _T("");
m_ourStaff = _T("");
m_clientStaff = _T("");
m_remark = _T("");
//}}AFX_DATA_INIT
}
void CClientProductForm::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CClientProductForm)
DDX_Control(pDX, IDC_clientStaff, m_clientStaffCombo);
DDX_Control(pDX, IDC_ourStaff, m_ourStaffCombo);
DDX_Control(pDX, IDC_LIST1, m_clientList);
DDX_Control(pDX, IDC_LIST2, m_productList);
DDX_DateTimeCtrl(pDX, IDC_beginDate, m_beginDate);
DDX_DateTimeCtrl(pDX, IDC_endDate, m_endDate);
DDX_CBString(pDX, IDC_productID, m_productID);
DDX_CBString(pDX, IDC_productName, m_productName);
DDX_Text(pDX, IDC_standard, m_standard);
DDX_Text(pDX, IDC_price, m_price);
DDX_Text(pDX, IDC_num, m_num);
DDX_Text(pDX, IDC_unit, m_unit);
DDX_Text(pDX, IDC_total, m_total);
DDX_Text(pDX, IDC_manageRange, m_manageRange);
DDX_CBString(pDX, IDC_ourStaff, m_ourStaff);
DDX_CBString(pDX, IDC_clientStaff, m_clientStaff);
DDX_Text(pDX, IDC_remark, m_remark);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CClientProductForm, CDialog)
//{{AFX_MSG_MAP(CClientProductForm)
ON_BN_CLICKED(IDC_add, OnAdd)
ON_BN_CLICKED(IDC_delete, OnDelete)
ON_BN_CLICKED(IDC_modify, OnModify)
ON_BN_CLICKED(IDC_save, OnSave)
ON_BN_CLICKED(IDC_cancelation, OnCancelation)
ON_BN_CLICKED(IDC_exit, OnExit)
ON_NOTIFY(NM_CLICK, IDC_LIST1, OnClickList1)
ON_NOTIFY(NM_CLICK, IDC_LIST2, OnClickList2)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CClientProductForm message handlers
BOOL CClientProductForm::OnInitDialog()
{
CDialog::OnInitDialog();
DWORD style;
style=m_clientList.GetExStyle();
style=(style|LVS_EX_GRIDLINES|LVS_EX_FULLROWSELECT)&(~LVS_EX_CHECKBOXES) ;
m_clientList.SetExtendedStyle(style);
m_clientList.InsertColumn(0,"客户编码",LVCFMT_LEFT,100);
m_clientList.InsertColumn(1,"单位名称",LVCFMT_LEFT,100);
m_clientList.InsertColumn(2,"联系人",LVCFMT_LEFT,100);
m_clientList.InsertColumn(3,"登记日期",LVCFMT_LEFT,100);
m_clientList.InsertColumn(4,"客户级别",LVCFMT_LEFT,100);
m_clientList.InsertColumn(5,"地区",LVCFMT_LEFT,100);
m_clientList.InsertColumn(6,"地址",LVCFMT_LEFT,100);
m_clientList.InsertColumn(7,"邮编",LVCFMT_LEFT,100);
m_clientList.InsertColumn(8,"电话",LVCFMT_LEFT,100);
m_clientList.InsertColumn(9,"传真",LVCFMT_LEFT,100);
m_clientList.InsertColumn(10,"网站",LVCFMT_LEFT,100);
m_clientList.InsertColumn(11,"eMail",LVCFMT_LEFT,100);
m_clientList.InsertColumn(12,"备注",LVCFMT_LEFT,100);
int i=0;
CString strSQL;
_RecordsetPtr m_pRecordset;
HRESULT hTRes;
hTRes = m_pRecordset.CreateInstance(_T("ADODB.Recordset"));
strSQL="select distinct staffName from staff";
hTRes = m_pRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
((CClientRelationshipApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
adOpenDynamic,adLockPessimistic,adCmdText);
while(!(m_pRecordset->adoEOF))
{
m_ourStaffCombo.InsertString(i,((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("staffName")));
m_pRecordset->MoveNext();
i++;
}
m_pRecordset->Close();
i=0;
strSQL="select distinct staffName from clientStaff";
hTRes = m_pRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
((CClientRelationshipApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
adOpenDynamic,adLockPessimistic,adCmdText);
while(!(m_pRecordset->adoEOF))
{
m_clientStaffCombo.InsertString(i,((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("staffName")));
m_pRecordset->MoveNext();
i++;
}
m_pRecordset->Close();
i=0;
_RecordsetPtr m_pClientRecordset;
strSQL="select * from client";
hTRes = m_pClientRecordset.CreateInstance(_T("ADODB.Recordset"));
if (SUCCEEDED(hTRes))
{
hTRes = m_pClientRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
((CClientRelationshipApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
adOpenDynamic,adLockPessimistic,adCmdText);
while(!(m_pClientRecordset->adoEOF))
{
m_clientList.InsertItem(i,((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pClientRecordset->GetCollect("clientID")));
m_clientList.SetItemText(i,1,((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pClientRecordset->GetCollect("clientName")));
m_clientList.SetItemText(i,2,((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pClientRecordset->GetCollect("contactPerson")));
m_clientList.SetItemText(i,3,((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pClientRecordset->GetCollect("bookinDate")));
m_clientList.SetItemText(i,4,((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pClientRecordset->GetCollect("clientLevel")));
m_clientList.SetItemText(i,5,((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pClientRecordset->GetCollect("areaID")));
m_clientList.SetItemText(i,6,((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pClientRecordset->GetCollect("address")));
m_clientList.SetItemText(i,7,((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pClientRecordset->GetCollect("postcode")));
m_clientList.SetItemText(i,8,((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pClientRecordset->GetCollect("telephone")));
m_clientList.SetItemText(i,9,((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pClientRecordset->GetCollect("fax")));
m_clientList.SetItemText(i,10,((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pClientRecordset->GetCollect("webSite")));
m_clientList.SetItemText(i,11,((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pClientRecordset->GetCollect("eMail")));
m_clientList.SetItemText(i,12,((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pClientRecordset->GetCollect("remark")));
i++;
m_pClientRecordset->MoveNext();
}
}
style=m_productList.GetExStyle();
style=(style|LVS_EX_GRIDLINES|LVS_EX_FULLROWSELECT)&(~LVS_EX_CHECKBOXES) ;
m_productList.SetExtendedStyle(style);
m_productList.InsertColumn(0,"产品编码",LVCFMT_LEFT,100);
m_productList.InsertColumn(1,"产品名称",LVCFMT_LEFT,100);
m_productList.InsertColumn(4,"产品规格",LVCFMT_LEFT,100);
m_productList.InsertColumn(2,"开始日期",LVCFMT_LEFT,100);
m_productList.InsertColumn(3,"结束日期",LVCFMT_LEFT,100);
m_productList.InsertColumn(5,"产品单价",LVCFMT_LEFT,100);
m_productList.InsertColumn(6,"产品数量",LVCFMT_LEFT,100);
m_productList.InsertColumn(7,"计量单位",LVCFMT_LEFT,100);
m_productList.InsertColumn(8,"成交金额",LVCFMT_LEFT,100);
m_productList.InsertColumn(9,"受理范围",LVCFMT_LEFT,100);
m_productList.InsertColumn(10,"我方人员",LVCFMT_LEFT,100);
m_productList.InsertColumn(11,"客户负责人",LVCFMT_LEFT,100);
m_productList.InsertColumn(12,"备注信息",LVCFMT_LEFT,100);
tx_beginDate=GetDlgItem(IDC_beginDate);
tx_endDate=GetDlgItem(IDC_endDate);
tx_productID=GetDlgItem(IDC_productID);
tx_productName=GetDlgItem(IDC_productName);
tx_standard=GetDlgItem(IDC_standard);
tx_price=GetDlgItem(IDC_price);
tx_num=GetDlgItem(IDC_num);
tx_unit=GetDlgItem(IDC_unit);
tx_total=GetDlgItem(IDC_total);
tx_manageRange=GetDlgItem(IDC_manageRange);
tx_ourStaff=GetDlgItem(IDC_ourStaff);
tx_clientStaff=GetDlgItem(IDC_clientStaff);
tx_remark=GetDlgItem(IDC_remark);
bt_add=GetDlgItem(IDC_add);
bt_delete=GetDlgItem(IDC_delete);
bt_modify=GetDlgItem(IDC_modify);
bt_cancelation=GetDlgItem(IDC_cancelation);
bt_save=GetDlgItem(IDC_save);
tx_beginDate->EnableWindow(false);
tx_endDate->EnableWindow(false);
tx_productID->EnableWindow(false);
tx_productName->EnableWindow(false);
tx_standard->EnableWindow(false);
tx_price->EnableWindow(false);
tx_num->EnableWindow(false);
tx_unit->EnableWindow(false);
tx_total->EnableWindow(false);
tx_manageRange->EnableWindow(false);
tx_ourStaff->EnableWindow(false);
tx_clientStaff->EnableWindow(false);
tx_remark->EnableWindow(false);
bt_add->EnableWindow(true);
bt_delete->EnableWindow(false);
bt_modify->EnableWindow(false);
bt_cancelation->EnableWindow(false);
bt_save->EnableWindow(false);
UpdateData(false);
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CClientProductForm::OnAdd()
{
tx_beginDate->EnableWindow(true);
tx_endDate->EnableWindow(true);
tx_productID->EnableWindow(false);
tx_productName->EnableWindow(true);
tx_standard->EnableWindow(true);
tx_price->EnableWindow(true);
tx_num->EnableWindow(true);
tx_unit->EnableWindow(true);
tx_total->EnableWindow(true);
tx_manageRange->EnableWindow(true);
tx_ourStaff->EnableWindow(true);
tx_clientStaff->EnableWindow(true);
tx_remark->EnableWindow(true);
bt_add->EnableWindow(false);
bt_delete->EnableWindow(false);
bt_modify->EnableWindow(false);
bt_cancelation->EnableWindow(true);
bt_save->EnableWindow(true);
CString m_formID;
int formID=((CClientRelationshipApp*)AfxGetApp())->m_pIDRecordset->GetCollect("clientProductID").intVal;
if(formID<10)
m_formID.Format("KHCP0000%d",formID);
else if(formID<100&&formID>9)
m_formID.Format("KHCP000%d",formID);
else if(formID<1000&&formID>99)
m_formID.Format("KHCP00%d",formID);
CString str;
str.Format("%d",formID+1);
((CClientRelationshipApp*)AfxGetApp())->m_pIDRecordset->PutCollect("clientProductID",_variant_t(str));
((CClientRelationshipApp*)AfxGetApp())->m_pIDRecordset->Update();
m_productID=m_formID;
m_beginDate = COleDateTime::GetCurrentTime();
m_endDate = COleDateTime::GetCurrentTime();
m_productName = _T("");
m_standard = _T("");
m_price = 0.0f;
m_num = 0;
m_unit = _T("");
m_total = 0.0f;
m_manageRange = _T("");
m_ourStaff = _T("");
m_clientStaff = _T("");
m_remark = _T("");
flag=1;
UpdateData(false);
}
void CClientProductForm::OnDelete()
{
UpdateData(true);
tx_beginDate->EnableWindow(false);
tx_endDate->EnableWindow(false);
tx_productID->EnableWindow(false);
tx_productName->EnableWindow(false);
tx_standard->EnableWindow(false);
tx_price->EnableWindow(false);
tx_num->EnableWindow(false);
tx_unit->EnableWindow(false);
tx_total->EnableWindow(false);
tx_manageRange->EnableWindow(false);
tx_ourStaff->EnableWindow(false);
tx_clientStaff->EnableWindow(false);
tx_remark->EnableWindow(false);
bt_add->EnableWindow(true);
bt_delete->EnableWindow(false);
bt_modify->EnableWindow(false);
bt_cancelation->EnableWindow(false);
bt_save->EnableWindow(false);
CClientProduct clientProduct;
clientProduct.sqlDelete(m_clientID,m_productID);
m_productID="";
m_beginDate = COleDateTime::GetCurrentTime();
m_endDate = COleDateTime::GetCurrentTime();
m_productName = _T("");
m_standard = _T("");
m_price = 0.0f;
m_num = 0;
m_unit = _T("");
m_total = 0.0f;
m_manageRange = _T("");
m_ourStaff = _T("");
m_clientStaff = _T("");
m_remark = _T("");
Refresh();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -