MissCall.cpp 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606
  1. // MissCall.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "MissCall.h"
  6. #include "MyMdi.H"
  7. #include "ModifyDinDan.h"
  8. #include "InputPsw.h"
  9. #include "ImportPhoto.h"
  10. #include "ShowPic.h"
  11. #ifdef _DEBUG
  12. #define new DEBUG_NEW
  13. #undef THIS_FILE
  14. static char THIS_FILE[] = __FILE__;
  15. #endif
  16. //#pragma comment(lib, "Shlwapi.lib")
  17. /////////////////////////////////////////////////////////////////////////////
  18. // MissCall
  19. IMPLEMENT_DYNCREATE(MissCall, MyFormView)
  20. MissCall::MissCall()
  21. : MyFormView(MissCall::IDD)
  22. {
  23. //{{AFX_DATA_INIT(MissCall)
  24. m_filter = _T("");
  25. //}}AFX_DATA_INIT
  26. }
  27. MissCall::~MissCall()
  28. {
  29. }
  30. void MissCall::DoDataExchange(CDataExchange* pDX)
  31. {
  32. MyFormView::DoDataExchange(pDX);
  33. //{{AFX_DATA_MAP(MissCall)
  34. DDX_Control(pDX, IDC_COMBO1, m_combo1);
  35. DDX_Control(pDX, IDC_LIST2, m_List1);
  36. DDX_Control(pDX, IDC_STATIC1, m_static1);
  37. DDX_CBString(pDX, IDC_COMBO1, m_filter);
  38. //}}AFX_DATA_MAP
  39. }
  40. BEGIN_MESSAGE_MAP(MissCall, MyFormView)
  41. //{{AFX_MSG_MAP(MissCall)
  42. ON_BN_CLICKED(IDC_BUTclose, OnBUTclose)
  43. ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
  44. ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1)
  45. ON_WM_TIMER()
  46. ON_BN_CLICKED(IDC_BUTimportphoto, OnBUTimportphoto)
  47. ON_BN_CLICKED(IDC_BUTshowphoto, OnBUTshowphoto)
  48. ON_BN_CLICKED(IDC_BUTexportphoto, OnBUTexportphoto)
  49. ON_BN_CLICKED(IDC_BUTexportphoto2, OnBUTexportphoto2)
  50. ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
  51. ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST2, OnItemchangedList2)
  52. ON_BN_CLICKED(IDC_BUTdel, OnBUTdel)
  53. //}}AFX_MSG_MAP
  54. END_MESSAGE_MAP()
  55. /////////////////////////////////////////////////////////////////////////////
  56. // MissCall diagnostics
  57. #ifdef _DEBUG
  58. void MissCall::AssertValid() const
  59. {
  60. MyFormView::AssertValid();
  61. }
  62. void MissCall::Dump(CDumpContext& dc) const
  63. {
  64. MyFormView::Dump(dc);
  65. }
  66. #endif //_DEBUG
  67. /////////////////////////////////////////////////////////////////////////////
  68. // MissCall message handlers
  69. void MissCall::OnInitialUpdate()
  70. {
  71. MyFormView::OnInitialUpdate();
  72. // TODO: Add your specialized code here and/or call the base class
  73. CMyMdi Mdi;
  74. Mdi.SetSubView((CWnd*)GetParent(), (CWnd*)this);
  75. // Here we create the outbar control using the splitter as its parent
  76. // and setting its id to the first pane.
  77. CRect rc2;
  78. GetWindowRect(rc2);
  79. ::MoveWindow(m_hWnd,g_rc.left,g_rc.top,g_rc.Width(),g_rc.Height(),TRUE);
  80. EnumChildWindows(m_hWnd,(WNDENUMPROC)EnumChildProc,0);
  81. m_static1.SetFont (&g_titlefont);
  82. m_List1.SetHeadings("姓名,160;电话号码,160;来电时间,160;类别,160" );
  83. m_List1.LoadColumnInfo (159);
  84. g_sendhead.bsql=0;
  85. g_sendhead.code[0]=117;
  86. g_sendhead.tabcount=1;
  87. g_pMainWnd->ProcessChatMessageRequest2(1);if(g_bSendOK==0)return;
  88. DataToArray(&m_List1array);
  89. FillGrid();
  90. m_combo1.GetWindowRect (rc2);
  91. ScreenToClient(rc2);
  92. rc2.bottom +=200;
  93. m_combo1.MoveWindow (rc2);
  94. GetDlgItem(IDC_BUTclose)->GetWindowRect(rc2);
  95. SetComboHei(&m_combo1, rc2.Height ());
  96. }
  97. void MissCall::FillGrid(BOOL bStatus)
  98. {
  99. m_List1.DeleteAllItems2 ();
  100. int ii=0;
  101. m_List1.m_arLabels.SetSize( m_List1array.GetSize (), 1 );
  102. int count=0;
  103. if(m_filter.IsEmpty ())
  104. {
  105. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  106. {
  107. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  108. }
  109. }
  110. else
  111. {
  112. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  113. {
  114. if(m_List1array.ElementAt (ii).ElementAt (0).Find (m_filter)!=-1 || \
  115. m_List1array.ElementAt (ii).ElementAt (1).Find (m_filter)!=-1 || \
  116. m_List1array.ElementAt (ii).ElementAt (2).Find (m_filter)!=-1 || \
  117. m_List1array.ElementAt (ii).ElementAt (3).Find (m_filter)!=-1 )
  118. {
  119. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  120. }
  121. }
  122. }
  123. m_List1.m_arLabels.SetSize(count, 1);
  124. ii=count;
  125. m_List1.m_LabelCount=ii;
  126. m_List1.SetItemCountEx (ii);
  127. }
  128. void MissCall::OnBUTclose()
  129. {
  130. // TODO: Add your control notification handler code here
  131. GetParent()->SendMessage(WM_CLOSE);
  132. }
  133. void MissCall::OnSelchangeCombo1()
  134. {
  135. // TODO: Add your control notification handler code here
  136. SetTimer(1, 100, NULL);
  137. }
  138. void MissCall::OnTimer(UINT nIDEvent)
  139. {
  140. // TODO: Add your message handler code here and/or call default
  141. KillTimer(nIDEvent);
  142. OnButton1();
  143. }
  144. BOOL MissCall::PreTranslateMessage(MSG* pMsg)
  145. {
  146. // TODO: Add your specialized code here and/or call the base class
  147. try
  148. {
  149. if(pMsg->message==WM_KEYDOWN)
  150. {
  151. switch (pMsg->wParam)
  152. {
  153. case VK_RETURN:
  154. OnButton1();
  155. return 1;
  156. case 0x43: // copy
  157. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  158. {
  159. GetFocus()->SendMessage(WM_COPY);
  160. return TRUE;
  161. }
  162. break;
  163. case 0x56: //Ctrl + V:
  164. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  165. {
  166. GetFocus()->SendMessage(WM_PASTE);
  167. return TRUE;
  168. }
  169. break;
  170. case 0x58: // cut
  171. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  172. {
  173. GetFocus()->SendMessage(WM_CUT);
  174. return TRUE;
  175. }
  176. break;
  177. case 0x5A: //undo
  178. case 0x59: //redo
  179. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  180. {
  181. GetFocus()->SendMessage(WM_UNDO);
  182. return TRUE;
  183. }
  184. break;
  185. }
  186. }
  187. return MyFormView::PreTranslateMessage(pMsg);
  188. }
  189. catch(...)
  190. {
  191. }
  192. }
  193. void MissCall::OnBUTimportphoto()
  194. {
  195. // TODO: Add your control notification handler code here
  196. POSITION pos;
  197. pos=m_List1.GetFirstSelectedItemPosition();
  198. if(pos==NULL)
  199. {
  200. AfxMessageBox("请先选中您要导片的定单!", MB_ICONINFORMATION);
  201. return;
  202. }
  203. int iItem=m_List1.GetNextSelectedItem(pos);
  204. CString id=m_List1.GetItemText (iItem, 0);
  205. CString oldstatus=m_List1.GetItemText (iItem, 4);
  206. CString name=m_List1.GetItemText (iItem, 1)+","+m_List1.GetItemText (iItem, 2);
  207. name.TrimLeft (",");
  208. name.TrimRight (",");
  209. name="客人:"+name;
  210. CString phone=m_List1.GetItemText (iItem, 12)+","+m_List1.GetItemText (iItem, 13);
  211. phone.TrimLeft (",");
  212. phone.TrimRight (",");
  213. phone="电话:"+phone;
  214. if(g_path2.IsEmpty ())
  215. {
  216. AfxMessageBox("未设置已修片保存机器, 请通知系统管理员!", MB_ICONINFORMATION);
  217. return;
  218. }
  219. if(!::CheckFolderFileExist (g_path2))
  220. {
  221. AfxMessageBox("已修片保存机器目录未设置, 请通知系统管理员!", MB_ICONINFORMATION);
  222. return;
  223. }
  224. CString savepath=g_path2+"\\";
  225. savepath+=id+"\\";
  226. if(::CheckFolderFileExist (savepath)==0)
  227. ::CreateDirectory (savepath, NULL);
  228. CFileDialog fdlg(true, NULL,"openfile", OFN_ALLOWMULTISELECT,"jpg文件(*.jpg)|*.jpg||");
  229. TCHAR szBuffer[60000]={0};
  230. fdlg.m_ofn.lpstrFile = szBuffer;
  231. fdlg.m_ofn.nMaxFile = 60000;
  232. if(fdlg.DoModal ()!=IDOK)
  233. {
  234. CString status4;
  235. if(AfxMessageBox("客照是否全部修饰完毕?", MB_YESNO|MB_ICONINFORMATION)==IDYES)
  236. status4="OK";
  237. else
  238. status4="修片中";
  239. CString sql;
  240. sql="update dindan set status4='"+status4+"' where id='"+id+"'";
  241. sql+=DINDAN_REF;
  242. g_sendhead.bsql=1;
  243. g_pMainWnd->ProcessChatMessageRequest2(sql);if(g_bSendOK==0)return;
  244. for(int i=0; i<m_List1array.GetSize (); i++)
  245. {
  246. if(id==m_List1array.ElementAt (i).ElementAt (0))
  247. {
  248. m_List1array.ElementAt (i).SetAt (4, status4);
  249. FillGrid();
  250. break;
  251. }
  252. }
  253. return;
  254. }
  255. pos=fdlg.GetStartPosition ();
  256. CStringArray array;
  257. CString str,temp;
  258. while(pos!=NULL)
  259. {
  260. str=fdlg.GetNextPathName (pos);
  261. temp=str.Right (str.GetLength ()-str.ReverseFind ('\\')-1);
  262. // temp=temp.Left (temp.Find ('.'));
  263. temp=temp.Left (temp.ReverseFind ('.'));
  264. if(CheckOK(temp)==0)
  265. {
  266. temp.Format ("%s.jpg\r\n文件名非法, 此文件将被忽略! 照片必须从软件中'导出原片'处导出, 文件名必须为3位数字!", temp);
  267. AfxMessageBox(temp, MB_ICONSTOP);
  268. continue;
  269. }
  270. array.Add(str);
  271. }
  272. if(array.GetSize ()==0)return;
  273. if(oldstatus!="未修")
  274. {
  275. str.Format ("%s\r\n%s\r\n此单已导入过修片,确认您选中的照片没有导入过吗? 否则会覆盖原来的照片, 是否继续?", name, phone );
  276. if(AfxMessageBox(str, MB_YESNO|MB_ICONSTOP)!=IDYES)
  277. return;
  278. }
  279. else
  280. {
  281. CString str;
  282. str.Format ("%s\r\n%s\r\n确认您选中的照片与客户资料相符吗? 是否继续?", name, phone );
  283. if(AfxMessageBox(str, MB_YESNO|MB_ICONINFORMATION)!=IDYES)
  284. return;
  285. }
  286. ImportPhoto dlg;
  287. dlg.m_pArray=&array;
  288. dlg.m_savepath =savepath;
  289. dlg.DoModal ();
  290. CString status4;
  291. if(AfxMessageBox("客照是否全部修饰完毕?", MB_YESNO|MB_ICONINFORMATION)==IDYES)
  292. status4="OK";
  293. else
  294. status4="修片中";
  295. CString sql;
  296. sql="update dindan set status4='"+status4+"',waiter5='"+g_user.name+"' where id='"+id+"'";
  297. sql+=DINDAN_REF;
  298. g_sendhead.bsql=1;
  299. g_pMainWnd->ProcessChatMessageRequest2(sql);if(g_bSendOK==0)return;
  300. savepath+="ok";
  301. ::DeleteFile (savepath);
  302. AfxMessageBox("导入客照成功!", MB_ICONINFORMATION);
  303. for(int i=0; i<m_List1array.GetSize (); i++)
  304. {
  305. if(id==m_List1array.ElementAt (i).ElementAt (0))
  306. {
  307. m_List1array.ElementAt (i).SetAt (4, status4);
  308. m_List1array.ElementAt (i).SetAt (8, g_user.name);
  309. FillGrid();
  310. break;
  311. }
  312. }
  313. }
  314. void MissCall::OnBUTshowphoto()
  315. {
  316. // TODO: Add your control notification handler code here
  317. POSITION pos;
  318. pos=m_List1.GetFirstSelectedItemPosition();
  319. if(pos==NULL)
  320. {
  321. AfxMessageBox("请先选中您要查看的定单!", MB_ICONINFORMATION);
  322. return;
  323. }
  324. int iItem=m_List1.GetNextSelectedItem(pos);
  325. CString status=m_List1.GetItemText (iItem, 4);
  326. CString id=m_List1.GetItemText (iItem, 0);
  327. if(status=="未修")
  328. {
  329. AfxMessageBox("此单未导片!", MB_ICONINFORMATION);
  330. return;
  331. }
  332. ShowPic dlg;
  333. dlg.m_mode=2;
  334. dlg.m_path=g_path2+"\\";
  335. dlg.m_path+=id;
  336. dlg.m_path +="\\";
  337. dlg.DoModal ();
  338. }
  339. void MissCall::OnBUTexportphoto()
  340. {
  341. // TODO: Add your control notification handler code here
  342. if(IsHasRights2new(8)==0)return;
  343. POSITION pos;
  344. pos=m_List1.GetFirstSelectedItemPosition();
  345. if(pos==NULL)
  346. {
  347. AfxMessageBox("请先选中您要导出片的定单!", MB_ICONINFORMATION);
  348. return;
  349. }
  350. int iItem=m_List1.GetNextSelectedItem(pos);
  351. CString id=m_List1.GetItemText (iItem, 0);
  352. CString path;
  353. path=g_path1+"\\";
  354. path+=id;
  355. path +="\\";
  356. CString temp;
  357. CStringArray array;
  358. using namespace helper_coffs;
  359. ffsco o;
  360. o.dirs(0);
  361. o.find(LPCSTR(path), LPCSTR("*.jpg"));
  362. ffsco::typeT coo;
  363. ffsco::typeT::iterator it;
  364. coo = o.co_file();
  365. for (it = coo.begin();
  366. coo.end() != it;
  367. it ++)
  368. {
  369. temp=(*it).c_str();
  370. if(temp.GetAt (temp.ReverseFind ('\\')+1)!='s')
  371. {
  372. array.Add (temp);
  373. }
  374. }
  375. if(array.GetSize ()==0)
  376. {
  377. AfxMessageBox("此单未导片!", MB_ICONINFORMATION);
  378. return;
  379. }
  380. CString dir;
  381. GetSavePath(dir);
  382. if(dir.IsEmpty())
  383. {
  384. return;
  385. }
  386. CString name1=m_List1.GetItemText (iItem, 1);
  387. CString name2=m_List1.GetItemText (iItem, 2);
  388. dir.TrimRight ('\\');
  389. dir+="\\";
  390. dir+=id;
  391. dir+=name1;
  392. dir+=name2;
  393. dir+="原片";
  394. dir+="\\";
  395. ::CreateDirectory (dir, NULL);
  396. ImportPhoto dlg;
  397. dlg.m_mode =1;
  398. dlg.m_pArray=&array;
  399. dlg.m_savepath =dir;
  400. dlg.DoModal (); AfxMessageBox("导片成功!", MB_ICONINFORMATION);
  401. }
  402. void MissCall::OnBUTexportphoto2()
  403. {
  404. if(IsHasRights2new(9)==0)return;
  405. // TODO: Add your control notification handler code here
  406. POSITION pos;
  407. pos=m_List1.GetFirstSelectedItemPosition();
  408. if(pos==NULL)
  409. {
  410. AfxMessageBox("请先选中您要导出片的定单!", MB_ICONINFORMATION);
  411. return;
  412. }
  413. int iItem=m_List1.GetNextSelectedItem(pos);
  414. CString id=m_List1.GetItemText (iItem, 0);
  415. CString path;
  416. path=g_path2+"\\";
  417. path+=id;
  418. path +="\\";
  419. CString temp;
  420. CStringArray array;
  421. using namespace helper_coffs;
  422. ffsco o;
  423. o.dirs(0);
  424. o.find(LPCSTR(path), LPCSTR("*.jpg"));
  425. ffsco::typeT coo;
  426. ffsco::typeT::iterator it;
  427. coo = o.co_file();
  428. for (it = coo.begin();
  429. coo.end() != it;
  430. it ++)
  431. {
  432. temp=(*it).c_str();
  433. if(temp.GetAt (temp.ReverseFind ('\\')+1)!='s')
  434. {
  435. array.Add (temp);
  436. }
  437. }
  438. if(array.GetSize ()==0)
  439. {
  440. AfxMessageBox("此单未导片!", MB_ICONINFORMATION);
  441. return;
  442. }
  443. CString dir;
  444. GetSavePath(dir);
  445. if(dir.IsEmpty())
  446. {
  447. return;
  448. }
  449. CString name1=m_List1.GetItemText (iItem, 1);
  450. CString name2=m_List1.GetItemText (iItem, 2);
  451. dir.TrimRight ('\\');
  452. dir+="\\";
  453. dir+=id;
  454. dir+=name1;
  455. dir+=name2;
  456. dir+="修好的片";
  457. dir+="\\";
  458. ::CreateDirectory (dir, NULL);
  459. ImportPhoto dlg;
  460. dlg.m_mode =1;
  461. dlg.m_pArray=&array;
  462. dlg.m_savepath =dir;
  463. dlg.DoModal (); AfxMessageBox("导片成功!", MB_ICONINFORMATION);
  464. }
  465. void MissCall::OnButton1()
  466. {
  467. // TODO: Add your control notification handler code here
  468. UpdateData();
  469. m_filter.TrimLeft ();
  470. m_filter.TrimRight ();
  471. FillGrid();
  472. }
  473. void MissCall::OnButton2()
  474. {
  475. // TODO: Add your control notification handler code here
  476. UpdateData();
  477. m_filter.TrimLeft ();
  478. m_filter.TrimRight ();
  479. FillGrid(1);
  480. }
  481. void MissCall::OnItemchangedList2(NMHDR* pNMHDR, LRESULT* pResult)
  482. {
  483. NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
  484. // TODO: Add your control notification handler code here
  485. POSITION pos;
  486. pos=m_List1.GetFirstSelectedItemPosition();
  487. if(pos==NULL)
  488. {
  489. return;
  490. }
  491. int iItem=m_List1.GetNextSelectedItem(pos);
  492. CString waiter5=m_List1.GetItemText (iItem, 8);
  493. if(waiter5.IsEmpty () && IsHasRights2new(5) || IsHasRights2new(49))
  494. {
  495. GetDlgItem(IDC_BUTimportphoto)->EnableWindow(1);
  496. }
  497. else if(waiter5==g_user.name && IsHasRights2new(5) )
  498. {
  499. GetDlgItem(IDC_BUTimportphoto)->EnableWindow(1);
  500. }
  501. else
  502. GetDlgItem(IDC_BUTimportphoto)->EnableWindow(0);
  503. *pResult = 0;
  504. }
  505. BOOL MissCall::CheckOK(CString name)
  506. {
  507. if(name.GetLength ()>4)return 0;
  508. for(int i=0; i<name.GetLength (); i++)
  509. {
  510. if(name.GetAt (i)<'0'||name.GetAt (i)>'9')return 0;
  511. }
  512. return 1;
  513. }
  514. void MissCall::OnBUTdel()
  515. {
  516. // TODO: Add your control notification handler code here
  517. if(IsHasRights2new(49)==0)return;
  518. // TODO: Add your control notification handler code here
  519. POSITION pos;
  520. pos=m_List1.GetFirstSelectedItemPosition();
  521. if(pos==NULL)
  522. {
  523. AfxMessageBox("请先选中您要删除的记录!", MB_ICONINFORMATION);
  524. return;
  525. }
  526. if(AfxMessageBox("删除后将无法恢复,是否继续?", MB_YESNO|MB_ICONINFORMATION)!=IDYES)return;
  527. int iItem=m_List1.GetNextSelectedItem(pos);
  528. CString datetime=m_List1.GetItemText (iItem, 2);
  529. CString sql;
  530. sql.Format ("delete from misscallrecord where datetime='%s' ", datetime);
  531. g_sendhead.bsql=1;
  532. g_pMainWnd->ProcessChatMessageRequest2(sql);if(g_bSendOK==0)return;
  533. g_sendhead.bsql=0;
  534. g_sendhead.code[0]=117;
  535. g_sendhead.tabcount=1;
  536. g_pMainWnd->ProcessChatMessageRequest2(1);if(g_bSendOK==0)return;
  537. DataToArray(&m_List1array);
  538. FillGrid();
  539. }