outsourcingDlg2.cpp 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535
  1. // outsourcingDlg2.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "outsourcingDlg2.h"
  6. #include "SelProvider.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. /////////////////////////////////////////////////////////////////////////////
  13. // outsourcingDlg2
  14. outsourcingDlg2::outsourcingDlg2(CWnd* pParent /*=NULL*/)
  15. : CDialog(outsourcingDlg2::IDD)
  16. {
  17. //{{AFX_DATA_INIT(outsourcingDlg2)IDC_COMBOid
  18. m_name1 = _T("");
  19. m_name2 = _T("");
  20. m_id = _T("");
  21. m_money1 = _T("");
  22. m_money2 = _T("");
  23. m_money3 = _T("");
  24. //}}AFX_DATA_INIT
  25. }
  26. void outsourcingDlg2::DoDataExchange(CDataExchange* pDX)
  27. {
  28. CDialog::DoDataExchange(pDX);
  29. //{{AFX_DATA_MAP(outsourcingDlg2)
  30. DDX_Control(pDX, IDC_LIST1, m_List1);
  31. DDX_Text(pDX, IDC_EDITname1, m_name1);
  32. DDX_Text(pDX, IDC_EDITname2, m_name2);
  33. DDX_Text(pDX, IDC_EDITid2, m_id);
  34. DDX_Text(pDX, IDC_EDITmoney1, m_money1);
  35. DDX_Text(pDX, IDC_EDITmoney2, m_money2);
  36. DDX_Text(pDX, IDC_EDITmoney3, m_money3);
  37. //}}AFX_DATA_MAP
  38. }
  39. BEGIN_MESSAGE_MAP(outsourcingDlg2, CDialog)
  40. //{{AFX_MSG_MAP(outsourcingDlg2)
  41. ON_BN_CLICKED(IDC_BUTclose, OnBUTclose)
  42. ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
  43. ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
  44. ON_BN_CLICKED(IDC_BUTget, OnBUTget)
  45. ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
  46. ON_BN_CLICKED(IDC_BUTTON4, OnButton4)
  47. ON_BN_CLICKED(IDC_BTNdel, OnBTNdel)
  48. ON_BN_CLICKED(IDC_BTNdel2, OnBTNdel2)
  49. ON_WM_TIMER()
  50. ON_WM_DESTROY()
  51. //}}AFX_MSG_MAP
  52. ON_WM_CTLCOLOR()
  53. END_MESSAGE_MAP()
  54. /////////////////////////////////////////////////////////////////////////////
  55. // outsourcingDlg2 diagnostics
  56. /////////////////////////////////////////////////////////////////////////////
  57. // outsourcingDlg2 message handlers
  58. BOOL outsourcingDlg2::PreTranslateMessage(MSG* pMsg)
  59. {
  60. // TODO: Add your specialized code here and/or call the base class
  61. if(pMsg->message==WM_LBUTTONDBLCLK)
  62. {//list1
  63. CPoint pt;
  64. CRect rc,rc2;
  65. ::GetCursorPos (&pt);
  66. m_List1.GetWindowRect (rc2);
  67. if(rc2.PtInRect (pt)==0) return CDialog::PreTranslateMessage(pMsg);
  68. pt.x-=rc2.left ;
  69. pt.y-=rc2.top ;
  70. int iItem=m_List1.GetItemCount ()-1;
  71. if(iItem<0)
  72. {
  73. m_List1.GetHeaderCtrl()->GetItemRect (0, rc);
  74. int hei=rc.Height ();
  75. rc.top +=hei;
  76. rc.bottom +=hei;
  77. if(rc.PtInRect (pt))
  78. {
  79. m_List1.InsertItem(m_List1.GetItemCount (), "");
  80. }
  81. m_List1.GetHeaderCtrl()->GetItemRect (1, rc);
  82. rc.top +=hei;
  83. rc.bottom +=hei;
  84. if(rc.PtInRect (pt))
  85. {
  86. m_List1.InsertItem(m_List1.GetItemCount (), "");
  87. }
  88. UpdateZ();
  89. }
  90. else
  91. {
  92. m_List1.GetSubItemRect( iItem, 0, LVIR_BOUNDS, rc);
  93. int hei=rc.Height ();
  94. rc.top +=hei;
  95. rc.bottom +=hei;
  96. if(rc.PtInRect (pt))
  97. {
  98. if(m_List1.GetItemText (iItem, 0).IsEmpty ())
  99. return CDialog::PreTranslateMessage(pMsg);
  100. m_List1.InsertItem(m_List1.GetItemCount (), "");
  101. UpdateZ();
  102. }
  103. }
  104. }
  105. return CDialog::PreTranslateMessage(pMsg);
  106. }
  107. void outsourcingDlg2::OnBUTclose() // 关闭按钮;
  108. {
  109. // TODO: Add your control notification handler code here
  110. CDialog::OnCancel ();
  111. }
  112. void outsourcingDlg2::GetData()
  113. {
  114. // TODO: Add your control notification handler code here
  115. if(g_bAllBranch==0)
  116. {
  117. CString filter="id='"+m_id+"';";
  118. g_sendhead.code[0]=36;
  119. g_sendhead.code[1]=9;
  120. g_sendhead.tabcount=2;
  121. g_sendhead.bsql=0;
  122. g_pMainWnd->ProcessChatMessageRequest2(filter);if(g_bSendOK==0)return;
  123. DataToArray(&m_sparray,&g_List1array);
  124. }
  125. else
  126. {
  127. g_pMainWnd->OnDisconnect();
  128. g_branchip=GetIP(m_branch);
  129. g_pMainWnd->OnDisconnect();
  130. g_branchname=m_branch;
  131. g_bBranchModify=1;
  132. CString filter="id='"+m_id+"';";
  133. g_sendhead.code[0]=36;
  134. g_sendhead.code[1]=9;
  135. g_sendhead.tabcount=2;
  136. g_sendhead.bsql=0;
  137. g_pMainWnd->ProcessChatMessageRequest2(filter);if(g_bSendOK==0)return;
  138. DataToArray(&m_sparray,&g_List1array);
  139. }
  140. m_List1.DeleteAllItems ();
  141. for(int i=0; i<m_sparray.GetSize (); i++)
  142. {
  143. m_List1.InsertItem(i, m_sparray.ElementAt (i).ElementAt (0));
  144. m_List1.SetItemText(i, 1, m_sparray.ElementAt (i).ElementAt (1));
  145. m_List1.SetItemText(i, 2, m_sparray.ElementAt (i).ElementAt (2));
  146. m_List1.SetItemText(i, 3, m_sparray.ElementAt (i).ElementAt (3));
  147. m_List1.SetItemText(i, 4, m_sparray.ElementAt (i).ElementAt (4));
  148. #if 0 // Jeff.delete;
  149. m_List1.SetItemText(i, 5, m_sparray.ElementAt (i).ElementAt (5));
  150. m_List1.SetItemText(i, 6, m_sparray.ElementAt (i).ElementAt (6));
  151. #else
  152. m_List1.SetItemText(i, 5, m_sparray.ElementAt (i).ElementAt (5));
  153. m_List1.SetItemText(i, 6, m_sparray.ElementAt (i).ElementAt (6));
  154. m_List1.SetItemText(i, 7, m_sparray.ElementAt (i).ElementAt (7));
  155. m_List1.SetItemText(i, 8, m_sparray.ElementAt (i).ElementAt (8));
  156. #endif
  157. }
  158. UpdateZ();
  159. }
  160. extern BOOL CALLBACK EnumChildProc2(HWND hwnd,LPARAM lParam);
  161. BOOL outsourcingDlg2::OnInitDialog()
  162. {
  163. CDialog::OnInitDialog();
  164. CRect rc2;
  165. GetWindowRect(rc2);
  166. ::MoveWindow(m_hWnd,g_rc.left,g_rc.top,g_rc.Width(),g_rc.Height(),TRUE);
  167. g_WidthScale2 = (float)g_rc.Width()/(float)rc2.Width(); // new/Old
  168. g_HeightScale2 = (float)g_rc.Height()/(float)rc2.Height();
  169. EnumChildWindows(m_hWnd,(WNDENUMPROC)EnumChildProc2,0);
  170. #ifdef CHILD_VERSION
  171. GetDlgItem(IDC_STATIC2)->SetWindowText("家长姓名:");
  172. GetDlgItem(IDC_STATIC4)->SetWindowText("宝宝姓名:");
  173. #endif
  174. // TODO: Add extra initialization here
  175. // Here we create the outbar control using the splitter as its parent
  176. // and setting its id to the first pane.
  177. m_List1.InitStyle();
  178. m_List1.InsertColumn(0,_T("相片名称"),LVCFMT_LEFT,300);
  179. m_List1.InsertColumn(1,_T("数量"),LVCFMT_LEFT,60);
  180. m_List1.InsertColumn(2,_T("面积"),LVCFMT_LEFT,80);
  181. m_List1.InsertColumn(3,_T("是否发出"),LVCFMT_LEFT,115);
  182. m_List1.InsertColumn(4,_T("发出日期"),LVCFMT_LEFT,90);
  183. #if 1// Jeff。添加 返工,返工日期;(与发件取片一样);
  184. m_List1.InsertColumn(5,_T("返工"),LVCFMT_LEFT,90);
  185. m_List1.InsertColumn(6,_T("返工日期"),LVCFMT_LEFT,90);
  186. m_List1.InsertColumn(7,_T("是否回来"),LVCFMT_LEFT,90);
  187. m_List1.InsertColumn(8,_T("回来日期"),LVCFMT_LEFT,90);
  188. #else
  189. m_List1.InsertColumn(5,_T("是否回来"),LVCFMT_LEFT,90);
  190. m_List1.InsertColumn(6,_T("回来日期"),LVCFMT_LEFT,90);
  191. #endif
  192. GetData();
  193. return TRUE; // return TRUE unless you set the focus to a control
  194. // EXCEPTION: OCX Property Pages should return FALSE
  195. }
  196. void outsourcingDlg2::OnOK() // 保存按钮;
  197. {
  198. // TODO: Add extra validation here
  199. m_sparray.RemoveAll ();
  200. m_sparray.SetSize(m_List1.GetItemCount ());
  201. int realcount=0;
  202. CString str;
  203. for(int i=0; i<m_List1.GetItemCount (); i++)
  204. {
  205. str=m_List1.GetItemText (i, 0);
  206. str.TrimLeft (); str.TrimRight ();
  207. if(str.IsEmpty ())continue;
  208. m_sparray.ElementAt (realcount).RemoveAll ();
  209. m_sparray.ElementAt (realcount).Add ( m_id );
  210. m_sparray.ElementAt (realcount).Add (m_List1.GetItemText (i, 0) );
  211. m_sparray.ElementAt (realcount).Add (m_List1.GetItemText (i, 1) );
  212. m_sparray.ElementAt (realcount).Add (m_List1.GetItemText (i, 2) );
  213. m_sparray.ElementAt (realcount).Add (m_List1.GetItemText (i, 3) );
  214. m_sparray.ElementAt (realcount).Add (m_List1.GetItemText (i, 4) );
  215. #if 0
  216. m_sparray.ElementAt (realcount).Add (m_List1.GetItemText (i, 5) );
  217. m_sparray.ElementAt (realcount).Add (m_List1.GetItemText (i, 6) );
  218. #else
  219. m_sparray.ElementAt (realcount).Add (m_List1.GetItemText (i, 5) ); // 返工;
  220. m_sparray.ElementAt (realcount).Add (m_List1.GetItemText (i, 6) ); // 返工日期;
  221. m_sparray.ElementAt (realcount).Add (m_List1.GetItemText (i, 7) ); // 取回状态;
  222. m_sparray.ElementAt (realcount).Add (m_List1.GetItemText (i, 8) ); // 取回日期;
  223. #endif
  224. realcount++;
  225. }
  226. m_sparray.SetSize(realcount);
  227. if(m_sparray.GetSize()==0)
  228. {
  229. m_sparray.SetSize(1);
  230. m_sparray.ElementAt(0).Add( m_id );
  231. }
  232. CMemFile memfile;
  233. CArchive ar(&memfile, CArchive::store);
  234. for(int ii=0; ii<m_sparray.GetSize(); ii++)
  235. {
  236. m_sparray.ElementAt(ii).Serialize(ar);
  237. }
  238. ar.Close();
  239. int length = memfile.GetLength ();
  240. BYTE *pData = memfile.Detach();
  241. int size = m_sparray.GetSize ();
  242. BYTE *pData2 = new BYTE[length+sizeof(int)];
  243. memcpy(pData2, pData, length);
  244. memcpy(pData2+length, &size, sizeof(int));
  245. delete []pData;
  246. length+=sizeof(int);
  247. g_nSendCode=13;
  248. g_pMainWnd->ProcessChatMessageRequest2(pData2, length);
  249. g_nSendCode=0;
  250. delete []pData2;
  251. if(g_bSendOK==0)return;
  252. AfxMessageBox("保存成功!", MB_ICONINFORMATION);
  253. CDialog::OnOK();
  254. }
  255. void outsourcingDlg2::OnButton1() // 全部发出按钮;
  256. {
  257. // TODO: Add your control notification handler code here
  258. SelProvider dlg;
  259. if(dlg.DoModal ()!=IDOK)return;
  260. for(int i=0; i<m_List1.GetItemCount (); i++)
  261. {
  262. m_List1.SetItemText (i, 3, dlg.m_provider);
  263. m_List1.SetItemText (i, 4, g_date);
  264. }
  265. }
  266. void outsourcingDlg2::OnButton3() // 全部发出-重置按钮;
  267. {
  268. // TODO: Add your control notification handler code here
  269. for(int i=0; i<m_List1.GetItemCount (); i++)
  270. {
  271. m_List1.SetItemText (i, 3, "");
  272. m_List1.SetItemText (i, 4, "");
  273. m_List1.SetItemText (i, 5, "");
  274. m_List1.SetItemText (i, 6, "");
  275. #if 1
  276. m_List1.SetItemText(i,7,"");
  277. m_List1.SetItemText(i,8,"");
  278. #endif
  279. }
  280. }
  281. void outsourcingDlg2::OnButton2() // 全部回来按钮;
  282. {
  283. // TODO: Add your control notification handler code here
  284. for(int i=0; i<m_List1.GetItemCount(); i++)
  285. {
  286. #if 0
  287. m_List1.SetItemText (i, 5, "OK");
  288. m_List1.SetItemText (i, 6, g_date);
  289. #else
  290. m_List1.SetItemText(i, 7, "OK");
  291. m_List1.SetItemText(i, 8, g_date);
  292. #endif
  293. }
  294. }
  295. void outsourcingDlg2::OnButton4() // 全部回来-重置按钮;
  296. {
  297. // TODO: Add your control notification handler code here
  298. for(int i=0; i<m_List1.GetItemCount (); i++)
  299. {
  300. #if 0
  301. m_List1.SetItemText (i, 5, "");
  302. m_List1.SetItemText (i, 6, "");
  303. #else
  304. m_List1.SetItemText(i, 7, "");
  305. m_List1.SetItemText(i, 8, "");
  306. #endif
  307. }
  308. }
  309. extern CString g_domain;
  310. void outsourcingDlg2::OnBUTget() // 从设计;
  311. {
  312. // TODO: Add your control notification handler code here
  313. if(m_List1.GetItemCount ())
  314. {
  315. if(AfxMessageBox("此单已有相片记录, 是否再次获取?", MB_YESNO|MB_ICONSTOP)!=IDYES)
  316. return;
  317. }
  318. // m_List1.DeleteAllItems ();
  319. CString m_path=g_path3+"\\";
  320. if(g_bAllBranch&&m_branch!="")
  321. {
  322. CString domain=GetDomainFromBranch(m_branch);
  323. if(domain!=g_domain)
  324. {
  325. m_path+=domain+"\\";
  326. }
  327. //CString GetDomainFromBranch(CString branch)
  328. }
  329. m_path+=m_id;
  330. m_path +="\\";
  331. CStringArray m_patharray1;
  332. if(1)
  333. {
  334. m_path.MakeLower ();
  335. CStringArray dirarray;
  336. CString str;
  337. if(1)
  338. {
  339. using namespace helper_coffs;
  340. ffsco o;
  341. o.dirs(1);
  342. o.find(LPCSTR(m_path), LPCSTR("*.*"));
  343. ffsco::typeT coo;
  344. ffsco::typeT::iterator it;
  345. coo = o.co_dir();
  346. for (it = coo.begin();coo.end() != it;it ++)
  347. {
  348. str=(*it).c_str();
  349. if(FindArray(&dirarray, str)==-1)
  350. {
  351. dirarray.Add (str);
  352. }
  353. }
  354. }
  355. if(1)
  356. {
  357. for(int i=0; i<dirarray.GetSize (); i++)
  358. {
  359. using namespace helper_coffs;
  360. ffsco o;
  361. o.dirs(0);
  362. o.find(LPCSTR(dirarray.ElementAt (i)), LPCSTR("*.jpg"));
  363. ffsco::typeT coo;
  364. ffsco::typeT::iterator it;
  365. coo = o.co_file();
  366. for (it = coo.begin();coo.end() != it;it ++)
  367. {
  368. str=(*it).c_str();
  369. if(str.GetAt (str.ReverseFind ('\\')+1)=='s')continue;
  370. if(str.GetAt (str.ReverseFind ('\\')+1)=='m')continue;
  371. str.MakeLower ();
  372. m_patharray1.Add (str);
  373. }
  374. }
  375. }
  376. }
  377. CString str,temp;
  378. int oldcount=m_List1.GetItemCount ();
  379. for(int i=oldcount; i<(m_patharray1.GetSize ()+oldcount); i++)
  380. {
  381. str=m_patharray1.ElementAt (i-oldcount);
  382. temp.Empty ();
  383. if(str.Left (str.ReverseFind ('\\')+1)!=m_path)
  384. {
  385. temp=str.Left (str.ReverseFind ('\\')+1);
  386. temp= temp.Right (temp.GetLength ()-m_path.GetLength ());
  387. }
  388. str=str.Right (str.GetLength ()-str.ReverseFind ('\\')-1);
  389. str=temp+str.Left (str.GetLength ()-4);
  390. m_List1.InsertItem(i, str);
  391. m_List1.SetItemText(i, 1, "1");
  392. str=m_patharray1.ElementAt (i-oldcount);
  393. Image *img=NULL;
  394. ::LoadImageFromBuf (&img, str);
  395. if(img->GetWidth())
  396. {
  397. float area=(img->GetWidth()*img->GetHeight()*0.0254*0.0254)/(img->GetHorizontalResolution()*img->GetHorizontalResolution());
  398. str.Format ("%0.5f", area);
  399. m_List1.SetItemText(i, 2, str);
  400. delete img;
  401. }
  402. }
  403. if(m_patharray1.GetSize ()==0)
  404. AfxMessageBox("此单未导入设计片!", MB_ICONINFORMATION);
  405. UpdateZ();
  406. }
  407. void outsourcingDlg2::OnBTNdel() // 删除按钮;
  408. {
  409. // TODO: Add your control notification handler code here
  410. POSITION pos;
  411. pos=m_List1.GetFirstSelectedItemPosition();
  412. if(pos==NULL)
  413. {
  414. AfxMessageBox("请先选中您要删除的项目!", MB_ICONINFORMATION);
  415. return;
  416. }
  417. int iItem=m_List1.GetNextSelectedItem(pos);
  418. m_List1.DeleteItem (iItem);
  419. int count=m_List1.GetItemCount ();
  420. if(count==0)
  421. {
  422. UpdateZ();
  423. return;
  424. }
  425. if(iItem==count)
  426. iItem=0;
  427. m_List1.SetItemState (iItem, LVIS_SELECTED, LVIS_SELECTED);
  428. UpdateZ();
  429. }
  430. void outsourcingDlg2::UpdateZ()
  431. {
  432. CString str;
  433. str.Format ("全部相片名细:%d", m_List1.GetItemCount());
  434. GetDlgItem(IDC_STATIC1)->SetWindowText( str);
  435. }
  436. void outsourcingDlg2::OnBTNdel2() // 从产品中获取;
  437. {
  438. // TODO: Add your control notification handler code here
  439. if(m_List1.GetItemCount ())
  440. {
  441. if(AfxMessageBox("此单已有相片记录, 是否再次获取?", MB_YESNO|MB_ICONSTOP)!=IDYES)
  442. return;
  443. }
  444. int count = m_List1.GetItemCount();
  445. #ifdef CHILD_VERSION
  446. CString filter="id='"+m_id+"' and name<>'入册' and name<>'入底'";
  447. #else
  448. CString filter="id='"+m_id+"' and kind<>'2' and name<>'入册' and name<>'入底'";
  449. #endif
  450. g_sendhead.code[0]=56; // Table is dindansp;
  451. g_sendhead.tabcount=1;
  452. g_sendhead.bsql=0;
  453. g_pMainWnd->ProcessChatMessageRequest2(filter);if(g_bSendOK==0)return;
  454. CArray<CStringArray, CStringArray>List1array;
  455. DataToArray(&List1array);
  456. for(int i=0; i<List1array.GetSize(); i++)
  457. {
  458. m_List1.InsertItem(count+i, List1array.ElementAt(i).ElementAt(0)); // 相片名称;
  459. m_List1.SetItemText(count+i, 1, List1array.ElementAt(i).ElementAt(1)); // 相片数量;
  460. //printf("Jeff:%s,%s\n\n",List1array.ElementAt(i).ElementAt(0),List1array.ElementAt(i).ElementAt(1));
  461. }
  462. UpdateZ();
  463. }
  464. void outsourcingDlg2::OnDestroy()
  465. {
  466. CDialog::OnDestroy();
  467. // TODO: Add your message handler code here
  468. if(g_bAllBranch)
  469. {
  470. g_pMainWnd->OnDisconnect();
  471. g_bBranchModify=0;g_branchip=g_branchname="";
  472. }
  473. }
  474. HBRUSH outsourcingDlg2::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
  475. {
  476. HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
  477. // TODO: 在此更改 DC 的任何属性
  478. if ( nCtlColor == CTLCOLOR_DLG )
  479. return g_dlgBrush;
  480. else if ( nCtlColor == CTLCOLOR_STATIC )
  481. {
  482. //pDC->SetBkColor(g_bkcol);
  483. pDC->SetBkMode(TRANSPARENT);
  484. hbr=(HBRUSH)g_dlgBrush;
  485. }
  486. // TODO: 如果默认的不是所需画笔,则返回另一个画笔
  487. return hbr;
  488. }