// CClientForm2.cpp : implementation file // #include "stdafx.h" #include "ylgl.h" #include "ClientForm2.h" #include "MyMdi.H" #include "SendMsgDlg.h" #include "SelBrunDevice.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CClientForm2 IMPLEMENT_DYNCREATE(CClientForm2, MyFormView) CClientForm2::CClientForm2() : MyFormView(CClientForm2::IDD) { //{{AFX_DATA_INIT(CClientForm2) m_filter = _T(""); m_from = _T(""); m_checkcontent = _T(""); m_clientqq = _T(""); m_contact = _T(""); m_clerk = g_user.name; m_useqq = _T(""); m_date = g_date; m_time.Format("%02d:%02d", CTime::GetCurrentTime().GetHour(), CTime::GetCurrentTime().GetMinute()); m_question = _T(""); m_solution = _T(""); m_result = _T(""); //}}AFX_DATA_INIT } CClientForm2::~CClientForm2() { } void CClientForm2::DoDataExchange(CDataExchange* pDX) { MyFormView::DoDataExchange(pDX); //{{AFX_DATA_MAP(CClientForm2) DDX_Control(pDX, IDC_COMBOresult, m_comboresult); DDX_Control(pDX, IDC_EDITdate, m_datectrl); DDX_Control(pDX, IDC_COMBOuseqq, m_combouseqq); DDX_Control(pDX, IDC_COMBOclerk, m_comboclerk); DDX_Control(pDX, IDC_COMBOcheckcontent, m_combocheckcontent); DDX_Control(pDX, IDC_COMBOfrom, m_combofrom); DDX_Control(pDX, IDC_COMBO1, m_combo1); DDX_Control(pDX, IDC_LIST2, m_List1); DDX_Control(pDX, IDC_STATIC1, m_static1); DDX_CBString(pDX, IDC_COMBO1, m_filter); DDX_CBString(pDX, IDC_COMBOfrom, m_from); DDX_CBString(pDX, IDC_COMBOcheckcontent, m_checkcontent); DDX_Text(pDX, IDC_EDITclientqq, m_clientqq); DDX_Text(pDX, IDC_EDITcontact, m_contact); DDX_CBString(pDX, IDC_COMBOclerk, m_clerk); DDX_CBString(pDX, IDC_COMBOuseqq, m_useqq); DDX_Text(pDX, IDC_EDITdate, m_date); DDX_Text(pDX, IDC_EDITtime, m_time); DDX_Text(pDX, IDC_EDITquestion, m_question); DDX_Text(pDX, IDC_EDITsolution, m_solution); DDX_CBString(pDX, IDC_COMBOresult, m_result); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CClientForm2, MyFormView) //{{AFX_MSG_MAP(CClientForm2) ON_BN_CLICKED(IDC_BUTclose, OnBUTclose) ON_BN_CLICKED(IDC_BUTTON1, OnButton1) ON_BN_CLICKED(IDC_BUTTON2, OnButton2) ON_BN_CLICKED(IDC_BUTTON3, OnButton3) ON_NOTIFY(NM_CLICK, IDC_LIST2, OnClickList2) ON_BN_CLICKED(IDC_BUTTON4, OnButton4) ON_CBN_CLOSEUP(IDC_COMBOcheckcontent, OnCloseupCOMBOcheckcontent) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CClientForm2 diagnostics #ifdef _DEBUG void CClientForm2::AssertValid() const { MyFormView::AssertValid(); } void CClientForm2::Dump(CDumpContext& dc) const { MyFormView::Dump(dc); } #endif //_DEBUG ///////////////////////////////////////////////////////////////////////////// // CClientForm2 message handlers void CClientForm2::OnInitialUpdate() { MyFormView::OnInitialUpdate(); // TODO: Add your specialized code here and/or call the base class CMyMdi Mdi; Mdi.SetSubView((CWnd*)GetParent(), (CWnd*)this); m_List1.m_bSortSupport = 0; GetDlgItem(IDC_BUTTON2)->EnableWindow(IsHasRights2new(49)); // Here we create the outbar control using the splitter as its parent // and setting its id to the first pane. CRect rc2; GetWindowRect(rc2); ::MoveWindow(m_hWnd, g_rc.left, g_rc.top, g_rc.Width(), g_rc.Height(), TRUE); EnumChildWindows(m_hWnd, (WNDENUMPROC)EnumChildProc, 0); GetDlgItem(IDC_BUTTON2)->EnableWindow(IsHasRights2new(49)); m_static1.SetFont(&g_titlefont); m_List1.SetHeadings("订单号,100;男宾姓名,100;女宾姓名,100;电话,100;地址,100;QQ,100;版本,100;业务员,100;检查内容,100;技术员,100;使用QQ,100;日期,100"); m_List1.LoadColumnInfo(108); g_sendhead.bsql = 0; g_sendhead.code[0] = 200; g_sendhead.code[1] = 201; g_sendhead.code[2] = 202; g_sendhead.code[3] = 203; g_sendhead.code[4] = 209; g_sendhead.tabcount = 5; g_pMainWnd->ProcessChatMessageRequest2(3); if (g_bSendOK == 0) { return; } CArrayList1array; CArrayList2array; CArrayList3array; CArrayList4array; int ii = 0; DataToArray(&List1array, &List2array, &List3array, &List4array, &m_List1array); for ( ii = 0; ii < List1array.GetSize(); ii++) m_combocheckcontent.AddString(List1array.ElementAt(ii).ElementAt(0)); for (ii = 0; ii < List2array.GetSize(); ii++) m_comboresult.AddString(List2array.ElementAt(ii).ElementAt(0)); for (ii = 0; ii < List3array.GetSize(); ii++) m_combouseqq.AddString(List3array.ElementAt(ii).ElementAt(0)); for (ii = 0; ii < List4array.GetSize(); ii++) m_combofrom.AddString(List4array.ElementAt(ii).ElementAt(0)); FillGrid(); m_combo1.GetWindowRect(rc2); ScreenToClient(rc2); rc2.bottom += 200; m_combo1.MoveWindow(rc2); GetDlgItem(IDC_BUTclose)->GetWindowRect(rc2); SetComboHei(&m_combo1, rc2.Height()); m_comboclerk.RefDroppedWidth(); m_comboclerk.AddString(g_user.name); m_comboclerk.SetCurSel(m_comboclerk.FindString(0, g_user.name)); } void CClientForm2::FillGrid() { m_List1.DeleteAllItems2(); int ii = 0; m_List1.m_arLabels.SetSize(m_List1array.GetSize(), 1); int count = 0; if (m_filter.IsEmpty()) { for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++) { m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii)); } } else { int type = GetType(m_filter); if (type == 1)//电话 { BOOL bFinded = 0; for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++) { if (bFinded && m_List1array.ElementAt(ii).ElementAt(0).IsEmpty()) { m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii)); continue; } if (m_List1array.ElementAt(ii).ElementAt(3).Find(m_filter) != -1) { bFinded = 1; m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii)); } else { bFinded = 0; } } } else if (type == 2)//拼音 { BOOL bFinded = 0; m_filter.MakeUpper(); for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++) { if (bFinded && m_List1array.ElementAt(ii).ElementAt(0).IsEmpty()) { m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii)); continue; } if (m_List1array.ElementAt(ii).ElementAt(20).Find(m_filter) != -1 || m_List1array.ElementAt(ii).ElementAt(21).Find(m_filter) != -1) { bFinded = 1; m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii)); } else { bFinded = 0; } } } else { BOOL bFinded = 0; for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++) { if (bFinded && m_List1array.ElementAt(ii).ElementAt(0).IsEmpty()) { m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii)); continue; } if (m_List1array.ElementAt(ii).ElementAt(0).Find(m_filter) != -1 || \ m_List1array.ElementAt(ii).ElementAt(1).Find(m_filter) != -1 || \ m_List1array.ElementAt(ii).ElementAt(2).Find(m_filter) != -1 || \ m_List1array.ElementAt(ii).ElementAt(3).Find(m_filter) != -1 || \ m_List1array.ElementAt(ii).ElementAt(4).Find(m_filter) != -1 || \ m_List1array.ElementAt(ii).ElementAt(5).Find(m_filter) != -1 || \ m_List1array.ElementAt(ii).ElementAt(6).Find(m_filter) != -1 || \ m_List1array.ElementAt(ii).ElementAt(7).Find(m_filter) != -1 || \ m_List1array.ElementAt(ii).ElementAt(8).Find(m_filter) != -1 || \ m_List1array.ElementAt(ii).ElementAt(9).Find(m_filter) != -1 || \ m_List1array.ElementAt(ii).ElementAt(10).Find(m_filter) != -1 || \ m_List1array.ElementAt(ii).ElementAt(11).Find(m_filter) != -1) { bFinded = 1; m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii)); } else { bFinded = 0; } } } } m_List1.m_arLabels.SetSize(count, 1); ii = count; m_List1.m_LabelCount = ii; m_List1.SetItemCountEx(ii); if (!g_id.IsEmpty()) { for (int i = 0; i < m_List1.GetItemCount(); i++) { if (g_id == m_List1.GetItemText(i, 0)) { m_List1.SetItemState(i, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED); m_List1.EnsureVisible(i, FALSE); break; } } } GetDlgItem(IDC_STATIC2)->SetWindowText(""); } void CClientForm2::OnBUTclose() { // TODO: Add your control notification handler code here GetParent()->SendMessage(WM_CLOSE); } BOOL CClientForm2::PreTranslateMessage(MSG* pMsg) { // TODO: Add your specialized code here and/or call the base class try { if (pMsg->message == WM_KEYDOWN) { switch (pMsg->wParam) { case VK_RETURN: OnButton1(); return 1; case 0x43: // copy if ((GetKeyState(VK_CONTROL) & 0x80)) { GetFocus()->SendMessage(WM_COPY); return TRUE; } break; case 0x56: //Ctrl + V: if ((GetKeyState(VK_CONTROL) & 0x80)) { GetFocus()->SendMessage(WM_PASTE); return TRUE; } break; case 0x58: // cut if ((GetKeyState(VK_CONTROL) & 0x80)) { GetFocus()->SendMessage(WM_CUT); return TRUE; } break; case 0x5A: //undo case 0x59: //redo if ((GetKeyState(VK_CONTROL) & 0x80)) { GetFocus()->SendMessage(WM_UNDO); return TRUE; } break; } } return MyFormView::PreTranslateMessage(pMsg); } catch (...) { } return true; } void CClientForm2::OnButton1() { // TODO: Add your control notification handler code here UpdateData(); m_filter.TrimLeft(); m_filter.TrimRight(); FillGrid(); } void CClientForm2::OnButton3() { UpdateData(); CString id; { POSITION pos; pos = m_List1.GetFirstSelectedItemPosition(); if (pos != NULL) { int iItem = m_List1.GetNextSelectedItem(pos); id = m_List1.GetItemText(iItem, 0); } else { AfxMessageBox("请先选中客户!", MB_ICONINFORMATION); return; } } m_from = m_checkcontent = m_clerk = m_useqq = ""; int pos = m_combofrom.GetCurSel(); if (pos != -1) { m_combofrom.GetLBText(pos, m_from); } pos = m_combocheckcontent.GetCurSel(); if (pos != -1) { m_combocheckcontent.GetLBText(pos, m_checkcontent); } pos = m_comboclerk.GetCurSel(); if (pos != -1) { m_comboclerk.GetLBText(pos, m_clerk); } pos = m_combouseqq.GetCurSel(); if (pos != -1) { m_combouseqq.GetLBText(pos, m_useqq); } pos = m_comboresult.GetCurSel(); if (pos != -1) { m_comboresult.GetLBText(pos, m_result); } if (!CheckDateOK(m_date))return; if (m_checkcontent == "电话回访") { if (m_result == "" || m_date == "") { AfxMessageBox("资料不全!", MB_ICONINFORMATION); return; return; } } else { if (m_result == "" || m_question == "" || m_from == "" || m_checkcontent == "" || m_clientqq == "" || m_clerk == "" || m_useqq == "" || m_date == "") { AfxMessageBox("资料不全!", MB_ICONINFORMATION); return; return; } } CString sql; if (m_autoid == "") sql.Format("insert into [clientservice]([id],[from],[checkcontent],[clientqq],[contact],[clerk],[useqq],[date],[time],[question],[solution],[result])values('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')", id, m_from, m_checkcontent, m_clientqq, m_contact, m_clerk, m_useqq, m_date, m_time, m_question, m_solution, m_result); else sql.Format("update [clientservice] set [from]='%s',[checkcontent]='%s',[clientqq]='%s',[contact]='%s',[clerk]='%s',[useqq]='%s',[date]='%s',[time]='%s',[question]='%s',[solution]='%s',[result]='%s' where [autoid]=%s", m_from, m_checkcontent, m_clientqq, m_contact, m_clerk, m_useqq, m_date, m_time, m_question, m_solution, m_result, m_autoid); g_sendhead.bsql = 1; g_pMainWnd->ProcessChatMessageRequest2(sql); if (g_bSendOK == 0)return; AfxMessageBox("保存成功!", MB_ICONINFORMATION); GetData(); } void CClientForm2::GetData() { g_sendhead.bsql = 0; g_sendhead.code[0] = 209; g_sendhead.tabcount = 1; g_pMainWnd->ProcessChatMessageRequest2(3); if (g_bSendOK == 0) { return; } DataToArray(&m_List1array); FillGrid(); } void CClientForm2::OnClickList2(NMHDR* pNMHDR, LRESULT* pResult) { // TODO: Add your control notification handler code here POSITION pos; pos = m_List1.GetFirstSelectedItemPosition(); if (pos == NULL) { OnButton4(); GetDlgItem(IDC_STATIC2)->SetWindowText(""); return; } int iItem = m_List1.GetNextSelectedItem(pos); CString id = m_List1.GetItemText(iItem, 0); int m_nitempos = 0; while (id == "") { m_nitempos++; iItem--; id = m_List1.GetItemText(iItem, 0); } g_id = id; CString str; str.Format("当前客人:%s %s", id, m_List1.GetItemText(iItem, 1) + m_List1.GetItemText(iItem, 2)); GetDlgItem(IDC_STATIC2)->SetWindowText(str); for (int i = 0; i < m_List1.m_arLabels.GetSize(); i++) { if (id == m_List1.m_arLabels.ElementAt(i).ElementAt(0)) { m_checkcontent = m_List1.m_arLabels.ElementAt(i + m_nitempos).ElementAt(8); m_clerk = m_List1.m_arLabels.ElementAt(i + m_nitempos).ElementAt(9); m_useqq = m_List1.m_arLabels.ElementAt(i + m_nitempos).ElementAt(10); m_date = m_List1.m_arLabels.ElementAt(i + m_nitempos).ElementAt(11); m_from = m_List1.m_arLabels.ElementAt(i + m_nitempos).ElementAt(12); m_clientqq = m_List1.m_arLabels.ElementAt(i + m_nitempos).ElementAt(13); m_contact = m_List1.m_arLabels.ElementAt(i + m_nitempos).ElementAt(14); m_time = m_List1.m_arLabels.ElementAt(i + m_nitempos).ElementAt(15); m_question = m_List1.m_arLabels.ElementAt(i + m_nitempos).ElementAt(16); m_solution = m_List1.m_arLabels.ElementAt(i + m_nitempos).ElementAt(17); m_result = m_List1.m_arLabels.ElementAt(i + m_nitempos).ElementAt(18); m_autoid = m_List1.m_arLabels.ElementAt(i + m_nitempos).ElementAt(19); m_combofrom.SetCurSel(-1); m_combocheckcontent.SetCurSel(-1); m_combouseqq.SetCurSel(-1); m_comboresult.SetCurSel(-1); UpdateData(0); if (m_comboclerk.FindString(0, m_clerk) == -1) m_comboclerk.AddString(m_clerk); m_comboclerk.SetCurSel(m_comboclerk.FindString(0, m_clerk)); if (m_comboresult.FindString(0, m_result) == -1) m_comboresult.AddString(m_result); m_comboresult.SetCurSel(m_comboresult.FindString(0, m_result)); if (m_autoid == "") OnButton4(); else { GetDlgItem(IDC_BUTTON3)->SetWindowText("保存更改"); if (g_user.name != m_clerk) GetDlgItem(IDC_BUTTON3)->EnableWindow(0); else GetDlgItem(IDC_BUTTON3)->EnableWindow(1); } return; } } *pResult = 0; } void CClientForm2::OnButton4() { // TODO: Add your control notification handler code here m_autoid = ""; m_from = _T(""); m_checkcontent = _T(""); m_clientqq = _T(""); m_contact = _T(""); m_clerk = g_user.name; m_useqq = _T(""); m_date = g_date; m_time.Format("%02d:%02d", CTime::GetCurrentTime().GetHour(), CTime::GetCurrentTime().GetMinute()); m_question = _T(""); m_solution = _T(""); m_result = _T(""); UpdateData(0); m_comboclerk.AddString(g_user.name); m_comboclerk.SetCurSel(m_comboclerk.FindString(0, g_user.name)); m_combofrom.SetCurSel(-1); m_combocheckcontent.SetCurSel(-1); m_combouseqq.SetCurSel(-1); m_comboresult.SetCurSel(-1); GetDlgItem(IDC_BUTTON3)->SetWindowText("保存"); GetDlgItem(IDC_BUTTON3)->EnableWindow(1); } void CClientForm2::OnButton2() { // TODO: Add your control notification handler code here POSITION pos; pos = m_List1.GetFirstSelectedItemPosition(); if (pos == NULL) { AfxMessageBox("请先选中您要删除的记录!", MB_ICONINFORMATION); return; } if (AfxMessageBox("确认删除此服务记录吗?", MB_YESNO | MB_ICONINFORMATION) != IDYES)return; int iItem = m_List1.GetNextSelectedItem(pos); CString id = m_List1.GetItemText(iItem, 0); int m_nitempos = 0; while (id == "") { m_nitempos++; iItem--; id = m_List1.GetItemText(iItem, 0); } CString str; str.Format("当前客人:%s %s", id, m_List1.GetItemText(iItem, 1) + m_List1.GetItemText(iItem, 2)); GetDlgItem(IDC_STATIC2)->SetWindowText(str); for (int i = 0; i < m_List1.m_arLabels.GetSize(); i++) { if (id == m_List1.m_arLabels.ElementAt(i).ElementAt(0)) { m_checkcontent = m_List1.m_arLabels.ElementAt(i + m_nitempos).ElementAt(8); m_clerk = m_List1.m_arLabels.ElementAt(i + m_nitempos).ElementAt(9); m_useqq = m_List1.m_arLabels.ElementAt(i + m_nitempos).ElementAt(10); m_date = m_List1.m_arLabels.ElementAt(i + m_nitempos).ElementAt(11); m_from = m_List1.m_arLabels.ElementAt(i + m_nitempos).ElementAt(12); m_clientqq = m_List1.m_arLabels.ElementAt(i + m_nitempos).ElementAt(13); m_contact = m_List1.m_arLabels.ElementAt(i + m_nitempos).ElementAt(14); m_time = m_List1.m_arLabels.ElementAt(i + m_nitempos).ElementAt(15); m_question = m_List1.m_arLabels.ElementAt(i + m_nitempos).ElementAt(16); m_solution = m_List1.m_arLabels.ElementAt(i + m_nitempos).ElementAt(17); m_result = m_List1.m_arLabels.ElementAt(i + m_nitempos).ElementAt(18); m_autoid = m_List1.m_arLabels.ElementAt(i + m_nitempos).ElementAt(19); UpdateData(0); if (m_comboclerk.FindString(0, m_clerk) == -1) m_comboclerk.AddString(m_clerk); m_comboclerk.SetCurSel(m_comboclerk.FindString(0, m_clerk)); if (m_autoid != "") { CString sql; sql.Format("delete from [clientservice] where [autoid]=%s", m_autoid); g_sendhead.bsql = 1; g_pMainWnd->ProcessChatMessageRequest2(sql); if (g_bSendOK == 0)return; GetData(); } } } } void CClientForm2::OnCloseupCOMBOcheckcontent() { // TODO: Add your control notification handler code here int pos = m_combocheckcontent.GetCurSel(); if (pos != -1) { m_checkcontent = ""; m_combocheckcontent.GetLBText(pos, m_checkcontent); } else return; if (m_checkcontent == "电话回访") { GetDlgItem(IDC_STATIC100)->SetWindowText("来源:"); GetDlgItem(IDC_STATIC101)->SetWindowText("反映问题:"); GetDlgItem(IDC_STATIC102)->SetWindowText("客户使用QQ:"); GetDlgItem(IDC_STATIC103)->SetWindowText("技术员:"); GetDlgItem(IDC_STATIC104)->SetWindowText("使用QQ:"); } else { GetDlgItem(IDC_STATIC100)->SetWindowText("*来源:"); GetDlgItem(IDC_STATIC101)->SetWindowText("*反映问题:"); GetDlgItem(IDC_STATIC102)->SetWindowText("*客户使用QQ:"); GetDlgItem(IDC_STATIC103)->SetWindowText("*技术员:"); GetDlgItem(IDC_STATIC104)->SetWindowText("*使用QQ:"); } }