outsourcingDlg2.cpp 14 KB

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