📄 clientcontactform.cpp
字号:
// ClientContactForm.cpp : implementation file
//
#include "stdafx.h"
#include "ClientRelationship.h"
#include "ClientContactForm.h"
#include "ClientContact.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CClientContactForm dialog
CClientContactForm::CClientContactForm(CWnd* pParent /*=NULL*/)
: CDialog(CClientContactForm::IDD, pParent)
{
//{{AFX_DATA_INIT(CClientContactForm)
m_contactSubject = _T("");
m_contactCondition = _T("");
m_contactSummary = _T("");
m_contactResult = _T("");
m_clientStaff = _T("");
m_ourStaff = _T("");
m_contactDate = COleDateTime::GetCurrentTime();
m_recordID = _T("");
//}}AFX_DATA_INIT
}
void CClientContactForm::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CClientContactForm)
DDX_Control(pDX, IDC_LIST2, m_contactList);
DDX_Control(pDX, IDC_LIST1, m_clientList);
DDX_Control(pDX, IDC_clientStaff, m_clientStaffCombo);
DDX_Control(pDX, IDC_ourStaff, m_ourStaffCombo);
DDX_Text(pDX, IDC_contactSubject, m_contactSubject);
DDX_Text(pDX, IDC_contactCondition, m_contactCondition);
DDX_Text(pDX, IDC_contactSummary, m_contactSummary);
DDX_CBString(pDX, IDC_contactResult, m_contactResult);
DDX_CBString(pDX, IDC_clientStaff, m_clientStaff);
DDX_CBString(pDX, IDC_ourStaff, m_ourStaff);
DDX_DateTimeCtrl(pDX, IDC_contactDate, m_contactDate);
DDX_Text(pDX, IDC_recordID, m_recordID);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CClientContactForm, CDialog)
//{{AFX_MSG_MAP(CClientContactForm)
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_LIST2, OnClickList2)
ON_NOTIFY(NM_CLICK, IDC_LIST1, OnClickList1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CClientContactForm message handlers
void CClientContactForm::OnAdd()
{
CString m_formID;
int formID=((CClientRelationshipApp*)AfxGetApp())->m_pIDRecordset->GetCollect("clientContactID").intVal;
if(formID<10)
m_formID.Format("KHJW0000%d",formID);
else if(formID<100&&formID>9)
m_formID.Format("KHJW000%d",formID);
else if(formID<1000&&formID>99)
m_formID.Format("KHJW00%d",formID);
CString str;
str.Format("%d",formID+1);
((CClientRelationshipApp*)AfxGetApp())->m_pIDRecordset->PutCollect("clientContactID",_variant_t(str));
((CClientRelationshipApp*)AfxGetApp())->m_pIDRecordset->Update();
m_recordID=m_formID;
m_contactSubject = _T("");
m_contactCondition = _T("");
m_contactSummary = _T("");
m_contactResult = _T("");
m_clientStaff = _T("");
m_ourStaff = _T("");
m_contactDate = COleDateTime::GetCurrentTime();
tx_contactSubject->EnableWindow(true);
tx_contactCondition->EnableWindow(true);
tx_contactSummary->EnableWindow(true);
tx_contactResult->EnableWindow(true);
tx_clientStaff->EnableWindow(true);
tx_ourStaff->EnableWindow(true);
tx_contactDate->EnableWindow(true);
tx_recordID->EnableWindow(false);
bt_add->EnableWindow(false);
bt_cancelation->EnableWindow(true);
bt_delete->EnableWindow(false);
bt_save->EnableWindow(true);
bt_modify->EnableWindow(false);
flag=1;
UpdateData(false);
}
void CClientContactForm::OnDelete()
{
CClientContact clientContact;
clientContact.sqlDelete(m_clientID,m_recordID);
m_contactSubject = _T("");
m_contactCondition = _T("");
m_contactSummary = _T("");
m_contactResult = _T("");
m_clientStaff = _T("");
m_ourStaff = _T("");
m_contactDate = COleDateTime::GetCurrentTime();
m_recordID="";
Refresh();
tx_contactSubject->EnableWindow(false);
tx_contactCondition->EnableWindow(false);
tx_contactSummary->EnableWindow(false);
tx_contactResult->EnableWindow(false);
tx_clientStaff->EnableWindow(false);
tx_ourStaff->EnableWindow(false);
tx_contactDate->EnableWindow(false);
tx_recordID->EnableWindow(false);
bt_add->EnableWindow(true);
bt_cancelation->EnableWindow(false);
bt_delete->EnableWindow(false);
bt_save->EnableWindow(false);
bt_modify->EnableWindow(false);
}
void CClientContactForm::OnModify()
{
tx_contactSubject->EnableWindow(true);
tx_contactCondition->EnableWindow(true);
tx_contactSummary->EnableWindow(true);
tx_contactResult->EnableWindow(true);
tx_clientStaff->EnableWindow(true);
tx_ourStaff->EnableWindow(true);
tx_contactDate->EnableWindow(true);
tx_recordID->EnableWindow(false);
bt_add->EnableWindow(false);
bt_cancelation->EnableWindow(false);
bt_delete->EnableWindow(false);
bt_save->EnableWindow(true);
bt_modify->EnableWindow(false);
flag=2;
}
void CClientContactForm::OnSave()
{
UpdateData(true);
CClientContact clientContact;
clientContact.SetClientID(m_clientID);
clientContact.SetContactID(m_recordID);
clientContact.SetContactSubject(m_contactSubject);
clientContact.SetContactCondition(m_contactCondition);
clientContact.SetContactSummary(m_contactSummary);
clientContact.SetContactResult(m_contactResult);
clientContact.SetClientStaff(m_clientStaff);
clientContact.SetOurStaff(m_ourStaff);
clientContact.SetContactDate(m_contactDate);
if(flag==1)
{
clientContact.sqlInsert();
int i=m_contactList.GetItemCount();
CString str;
m_contactList.InsertItem(i,m_recordID);
str.Format("%d-%d-%d",m_contactDate.GetYear(),m_contactDate.GetMonth(),m_contactDate.GetDay());
m_contactList.SetItemText(i,1,str);
m_contactList.SetItemText(i,2,m_ourStaff);
m_contactList.SetItemText(i,3,m_clientStaff);
m_contactList.SetItemText(i,4,m_contactSubject);
m_contactList.SetItemText(i,5,m_contactCondition);
m_contactList.SetItemText(i,6,m_contactSummary);
m_contactList.SetItemText(i,7,m_contactResult);
}
else if(flag==2)
{
clientContact.sqlUpdate(m_clientID,m_recordID);
Refresh();
}
tx_contactSubject->EnableWindow(false);
tx_contactCondition->EnableWindow(false);
tx_contactSummary->EnableWindow(false);
tx_contactResult->EnableWindow(false);
tx_clientStaff->EnableWindow(false);
tx_ourStaff->EnableWindow(false);
tx_contactDate->EnableWindow(false);
tx_recordID->EnableWindow(false);
bt_add->EnableWindow(true);
bt_cancelation->EnableWindow(false);
bt_delete->EnableWindow(true);
bt_save->EnableWindow(false);
bt_modify->EnableWindow(true);
}
void CClientContactForm::OnCancelation()
{
CString m_formID;
int formID=((CClientRelationshipApp*)AfxGetApp())->m_pIDRecordset->GetCollect("clientContactID").intVal;
if(formID<10)
m_formID.Format("KHJW0000%d",formID);
else if(formID<100&&formID>9)
m_formID.Format("KHJW000%d",formID);
else if(formID<1000&&formID>99)
m_formID.Format("KHJW00%d",formID);
CString str;
str.Format("%d",formID-1);
((CClientRelationshipApp*)AfxGetApp())->m_pIDRecordset->PutCollect("clientContactID",_variant_t(str));
((CClientRelationshipApp*)AfxGetApp())->m_pIDRecordset->Update();
m_contactSubject = _T("");
m_contactCondition = _T("");
m_contactSummary = _T("");
m_contactResult = _T("");
m_clientStaff = _T("");
m_ourStaff = _T("");
m_contactDate = COleDateTime::GetCurrentTime();
m_recordID="";
tx_contactSubject->EnableWindow(false);
tx_contactCondition->EnableWindow(false);
tx_contactSummary->EnableWindow(false);
tx_contactResult->EnableWindow(false);
tx_clientStaff->EnableWindow(false);
tx_ourStaff->EnableWindow(false);
tx_contactDate->EnableWindow(false);
tx_recordID->EnableWindow(false);
bt_add->EnableWindow(true);
bt_cancelation->EnableWindow(false);
bt_delete->EnableWindow(false);
bt_save->EnableWindow(false);
bt_modify->EnableWindow(false);
UpdateData(false);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -