// 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; iiGetWindowRect(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; iiSetWindowText(""); } 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(...) { } } 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; iSetWindowText("保存更改"); 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; iProcessChatMessageRequest2(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:"); } }