📄 clientreserveform.cpp
字号:
m_clientName = _T("");
m_clientStaff = _T("");
m_telephone = _T("");
m_subject = _T("");
m_address = _T("");
m_content = _T("");
m_remindNum = 0;
m_is_everyDay = FALSE;
m_clientReserveID = _T("");
tx_reserveTime->EnableWindow(false);
tx_reserveStyle->EnableWindow(false);
tx_attendStaff->EnableWindow(false);
tx_clientName->EnableWindow(false);
tx_clientStaff->EnableWindow(false);
tx_telephone->EnableWindow(false);
tx_subject->EnableWindow(false);
tx_address->EnableWindow(false);
tx_content->EnableWindow(false);
tx_remindNum->EnableWindow(false);
tx_is_everyDay->EnableWindow(false);
tx_clientReserveID->EnableWindow(false);
bt_add->EnableWindow(true);
bt_delete->EnableWindow(false);
bt_modify->EnableWindow(false);
bt_cancelation->EnableWindow(false);
bt_save->EnableWindow(false);
UpdateData(false);
}
void CClientReserveForm::OnExit()
{
this->OnCancel();
}
BOOL CClientReserveForm::OnInitDialog()
{
CDialog::OnInitDialog();
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);
m_list.InsertColumn(7,"预约主题",LVCFMT_LEFT,100);
m_list.InsertColumn(8,"预约地址",LVCFMT_LEFT,100);
m_list.InsertColumn(9,"预约内容",LVCFMT_LEFT,100);
m_list.InsertColumn(10,"提醒时间",LVCFMT_LEFT,100);
m_list.InsertColumn(11,"每天提醒",LVCFMT_LEFT,100);
CString strSQL;
_RecordsetPtr m_pRecordset;
HRESULT hTRes;
hTRes = m_pRecordset.CreateInstance(_T("ADODB.Recordset"));
strSQL="select distinct clientName from client";
hTRes = m_pRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
((CClientRelationshipApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
adOpenDynamic,adLockPessimistic,adCmdText);
int i=0;
while(!(m_pRecordset->adoEOF))
{
m_clientNameCombo.InsertString(i,((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("clientName")));
m_pRecordset->MoveNext();
i++;
}
m_pRecordset->Close();
strSQL="select distinct staffName from staff";
hTRes = m_pRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
((CClientRelationshipApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
adOpenDynamic,adLockPessimistic,adCmdText);
i=0;
while(!(m_pRecordset->adoEOF))
{
m_staffNameCombo.InsertString(i,((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("staffName")));
m_pRecordset->MoveNext();
i++;
}
m_pRecordset->Close();
strSQL="select distinct staffName from clientStaff";
hTRes = m_pRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
((CClientRelationshipApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
adOpenDynamic,adLockPessimistic,adCmdText);
i=0;
while(!(m_pRecordset->adoEOF))
{
m_clientStaffCombo.InsertString(i,((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("staffName")));
m_pRecordset->MoveNext();
i++;
}
m_pRecordset->Close();
strSQL="select * from clientReserve";
hTRes = m_pRecordset.CreateInstance(_T("ADODB.Recordset"));
hTRes = m_pRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
((CClientRelationshipApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
adOpenDynamic,adLockPessimistic,adCmdText);
CString str;
i=0;
while(!(m_pRecordset->adoEOF))
{
m_list.InsertItem(i,((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("clientReserveID")));
COleDateTime reserveTime= m_pRecordset->GetCollect("reserveTime");
str.Format("%d-%d-%d",reserveTime.GetYear(),reserveTime.GetMonth(),reserveTime.GetDay);
m_list.SetItemText(i,1,str);
m_list.SetItemText(i,2, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("reserveStyle")));
m_list.SetItemText(i,3, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("attendStaff")));
m_list.SetItemText(i,4, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("clientName")));
m_list.SetItemText(i,5, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("clientStaff")));
m_list.SetItemText(i,6, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("telephone")));
m_list.SetItemText(i,7, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("subject")));
m_list.SetItemText(i,8, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("address")));
m_list.SetItemText(i,9, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("content")));
m_list.SetItemText(i,10, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("remindNum")));
// is_everyDay= ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("isEveryDay"));
m_pRecordset->MoveNext();
i++;
}
tx_reserveTime=GetDlgItem(IDC_reserveTime);
tx_reserveStyle=GetDlgItem(IDC_reserveStyle);
tx_attendStaff=GetDlgItem(IDC_attendStaff);
tx_clientName=GetDlgItem(IDC_clientName);
tx_clientStaff=GetDlgItem(IDC_clientStaff);
tx_telephone=GetDlgItem(IDC_telephone);
tx_subject=GetDlgItem(IDC_subject);
tx_address=GetDlgItem(IDC_address);
tx_content=GetDlgItem(IDC_content);
tx_remindNum=GetDlgItem(IDC_remindNum);
tx_is_everyDay=GetDlgItem(IDC_CHECK1);
tx_clientReserveID=GetDlgItem(IDC_clientReserveID);
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_reserveTime->EnableWindow(false);
tx_reserveStyle->EnableWindow(false);
tx_attendStaff->EnableWindow(false);
tx_clientName->EnableWindow(false);
tx_clientStaff->EnableWindow(false);
tx_telephone->EnableWindow(false);
tx_subject->EnableWindow(false);
tx_address->EnableWindow(false);
tx_content->EnableWindow(false);
tx_remindNum->EnableWindow(false);
tx_is_everyDay->EnableWindow(false);
tx_clientReserveID->EnableWindow(false);
if(is_search==0)
{
bt_add->EnableWindow(true);
bt_delete->EnableWindow(false);
bt_modify->EnableWindow(false);
bt_cancelation->EnableWindow(false);
bt_save->EnableWindow(false);
}
else if(is_search==1)
{
CClientReserve clientReserve;
clientReserve.GetData(m_clientReserveID);
m_reserveTime = clientReserve.GetReserveTime();
m_reserveStyle = clientReserve.GetReserveStyle();
m_attendStaff = clientReserve.GetAttendStaff();
m_clientName = clientReserve.GetClientName();
m_clientStaff = clientReserve.GetClientStaff();
m_telephone = clientReserve.GetTelephone();
m_subject = clientReserve.GetSubject();
m_address = clientReserve.GetAddress();
m_content = clientReserve.GetContent();
m_remindNum = clientReserve.GetRemindNum();
// m_is_everyDay = FALSE;
bt_add->EnableWindow(true);
bt_delete->EnableWindow(true);
bt_modify->EnableWindow(true);
bt_cancelation->EnableWindow(false);
bt_save->EnableWindow(false);
}
UpdateData(false);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CClientReserveForm::OnClickList1(NMHDR* pNMHDR, LRESULT* pResult)
{
UpdateData(true);
POSITION pos = m_list.GetFirstSelectedItemPosition();
if(pos)
{
int nFirstSelItem = m_list.GetNextSelectedItem(pos);
m_clientReserveID=m_list.GetItemText(nFirstSelItem,0);
}
CClientReserve clientReserve;
clientReserve.GetData(m_clientReserveID);
m_reserveTime = clientReserve.GetReserveTime();
m_reserveStyle = clientReserve.GetReserveStyle();
m_attendStaff = clientReserve.GetAttendStaff();
m_clientName = clientReserve.GetClientName();
m_clientStaff = clientReserve.GetClientStaff();
m_telephone = clientReserve.GetTelephone();
m_subject = clientReserve.GetSubject();
m_address = clientReserve.GetAddress();
m_content = clientReserve.GetContent();
m_remindNum = clientReserve.GetRemindNum();
// m_is_everyDay = FALSE;
tx_reserveTime->EnableWindow(false);
tx_reserveStyle->EnableWindow(false);
tx_attendStaff->EnableWindow(false);
tx_clientName->EnableWindow(false);
tx_clientStaff->EnableWindow(false);
tx_telephone->EnableWindow(false);
tx_subject->EnableWindow(false);
tx_address->EnableWindow(false);
tx_content->EnableWindow(false);
tx_remindNum->EnableWindow(false);
tx_is_everyDay->EnableWindow(false);
tx_clientReserveID->EnableWindow(false);
bt_add->EnableWindow(true);
bt_delete->EnableWindow(true);
bt_modify->EnableWindow(true);
bt_cancelation->EnableWindow(false);
bt_save->EnableWindow(false);
UpdateData(false);
*pResult = 0;
}
void CClientReserveForm::Refresh()
{
m_list.DeleteAllItems();
CString strSQL;
_RecordsetPtr m_pRecordset;
HRESULT hTRes;
strSQL="select * from clientReserve";
hTRes = m_pRecordset.CreateInstance(_T("ADODB.Recordset"));
hTRes = m_pRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
((CClientRelationshipApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
adOpenDynamic,adLockPessimistic,adCmdText);;
CString str;
int i=0;
while(!(m_pRecordset->adoEOF))
{
m_list.InsertItem(i,((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("clientReserveID")));
COleDateTime reserveTime= m_pRecordset->GetCollect("reserveTime");
str.Format("%d-%d-%d",reserveTime.GetYear(),reserveTime.GetMonth(),reserveTime.GetDay);
m_list.SetItemText(i,1,str);
m_list.SetItemText(i,2, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("reserveStyle")));
m_list.SetItemText(i,3, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("attendStaff")));
m_list.SetItemText(i,4, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("clientName")));
m_list.SetItemText(i,5, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("clientStaff")));
m_list.SetItemText(i,6, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("telephone")));
m_list.SetItemText(i,7, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("subject")));
m_list.SetItemText(i,8, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("address")));
m_list.SetItemText(i,9, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("content")));
m_list.SetItemText(i,10, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("remindNum")));
// is_everyDay= ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("isEveryDay"));
m_pRecordset->MoveNext();
i++;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -