outsourcingDlg2.cpp 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  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. m_List1.SetItemText(i, 5, m_sparray.ElementAt (i).ElementAt (5));
  148. m_List1.SetItemText(i, 6, m_sparray.ElementAt (i).ElementAt (6));
  149. }
  150. UpdateZ();
  151. }
  152. extern BOOL CALLBACK EnumChildProc2(HWND hwnd,LPARAM lParam);
  153. extern float m_WidthScale2;
  154. extern float m_HeightScale2;
  155. BOOL outsourcingDlg2::OnInitDialog()
  156. {
  157. CDialog::OnInitDialog();
  158. CRect rc2;
  159. GetWindowRect(rc2);
  160. ::MoveWindow(m_hWnd,g_rc.left,g_rc.top,g_rc.Width(),g_rc.Height(),TRUE);
  161. m_WidthScale2 = (float)g_rc.Width()/(float)rc2.Width(); // new/Old
  162. m_HeightScale2 = (float)g_rc.Height()/(float)rc2.Height();
  163. EnumChildWindows(m_hWnd,(WNDENUMPROC)EnumChildProc2,0);
  164. #ifdef CHILD_VERSION
  165. GetDlgItem(IDC_STATIC2)->SetWindowText("家长姓名:");
  166. GetDlgItem(IDC_STATIC4)->SetWindowText("宝宝姓名:");
  167. #endif
  168. // TODO: Add extra initialization here
  169. // Here we create the outbar control using the splitter as its parent
  170. // and setting its id to the first pane.
  171. m_List1.InitStyle();
  172. m_List1.InsertColumn(0,_T("相片名称"),LVCFMT_LEFT,300);
  173. m_List1.InsertColumn(1,_T("数量"),LVCFMT_LEFT,60);
  174. m_List1.InsertColumn(2,_T("面积"),LVCFMT_LEFT,80);
  175. m_List1.InsertColumn(3,_T("是否发出"),LVCFMT_LEFT,115);
  176. m_List1.InsertColumn(4,_T("发出日期"),LVCFMT_LEFT,90);
  177. m_List1.InsertColumn(5,_T("是否回来"),LVCFMT_LEFT,90);
  178. m_List1.InsertColumn(6,_T("回来日期"),LVCFMT_LEFT,90);
  179. GetData();
  180. return TRUE; // return TRUE unless you set the focus to a control
  181. // EXCEPTION: OCX Property Pages should return FALSE
  182. }
  183. void outsourcingDlg2::OnOK()
  184. {
  185. // TODO: Add extra validation here
  186. m_sparray.RemoveAll ();
  187. m_sparray.SetSize(m_List1.GetItemCount ());
  188. int realcount=0;
  189. CString str;
  190. for(int i=0; i<m_List1.GetItemCount (); i++)
  191. {
  192. str=m_List1.GetItemText (i, 0);
  193. str.TrimLeft (); str.TrimRight ();
  194. if(str.IsEmpty ())continue;
  195. m_sparray.ElementAt (realcount).RemoveAll ();
  196. m_sparray.ElementAt (realcount).Add ( m_id );
  197. m_sparray.ElementAt (realcount).Add (m_List1.GetItemText (i, 0) );
  198. m_sparray.ElementAt (realcount).Add (m_List1.GetItemText (i, 1) );
  199. m_sparray.ElementAt (realcount).Add (m_List1.GetItemText (i, 2) );
  200. m_sparray.ElementAt (realcount).Add (m_List1.GetItemText (i, 3) );
  201. m_sparray.ElementAt (realcount).Add (m_List1.GetItemText (i, 4) );
  202. m_sparray.ElementAt (realcount).Add (m_List1.GetItemText (i, 5) );
  203. m_sparray.ElementAt (realcount).Add (m_List1.GetItemText (i, 6) );
  204. realcount++;
  205. }
  206. m_sparray.SetSize(realcount);
  207. if(m_sparray.GetSize ()==0)
  208. {
  209. m_sparray.SetSize(1);
  210. m_sparray.ElementAt (0).Add ( m_id );
  211. }
  212. CMemFile memfile;
  213. CArchive ar(&memfile, CArchive::store);
  214. for(int ii=0; ii<m_sparray.GetSize (); ii++)
  215. {
  216. m_sparray.ElementAt (ii).Serialize (ar);
  217. }
  218. ar.Close();
  219. int length=memfile.GetLength ();
  220. BYTE *pData = memfile.Detach();
  221. int size=m_sparray.GetSize ();
  222. BYTE *pData2=new BYTE[length+sizeof(int)];
  223. memcpy(pData2, pData, length);
  224. memcpy(pData2+length, &size, sizeof(int));
  225. delete []pData;
  226. length+=sizeof(int);
  227. g_nSendCode=13;
  228. g_pMainWnd->ProcessChatMessageRequest2(pData2, length);
  229. g_nSendCode=0;
  230. delete []pData2;
  231. if(g_bSendOK==0)return;
  232. AfxMessageBox("保存成功!", MB_ICONINFORMATION);
  233. CDialog::OnOK();
  234. }
  235. void outsourcingDlg2::OnButton1()
  236. {
  237. // TODO: Add your control notification handler code here
  238. SelProvider dlg;
  239. if(dlg.DoModal ()!=IDOK)return;
  240. for(int i=0; i<m_List1.GetItemCount (); i++)
  241. {
  242. m_List1.SetItemText (i, 3, dlg.m_provider);
  243. m_List1.SetItemText (i, 4, g_date);
  244. }
  245. }
  246. void outsourcingDlg2::OnButton3()
  247. {
  248. // TODO: Add your control notification handler code here
  249. for(int i=0; i<m_List1.GetItemCount (); i++)
  250. {
  251. m_List1.SetItemText (i, 6, "");
  252. m_List1.SetItemText (i, 3, "");
  253. m_List1.SetItemText (i, 4, "");
  254. m_List1.SetItemText (i, 5, "");
  255. }
  256. }
  257. void outsourcingDlg2::OnButton2()
  258. {
  259. // TODO: Add your control notification handler code here
  260. for(int i=0; i<m_List1.GetItemCount (); i++)
  261. {
  262. m_List1.SetItemText (i, 5, "OK");
  263. m_List1.SetItemText (i, 6, g_date);
  264. }
  265. }
  266. void outsourcingDlg2::OnButton4()
  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, 5, "");
  272. m_List1.SetItemText (i, 6, "");
  273. }
  274. }
  275. void outsourcingDlg2::OnBUTget()
  276. {
  277. // TODO: Add your control notification handler code here
  278. if(m_List1.GetItemCount ())
  279. {
  280. if(AfxMessageBox("此单已有相片记录, 是否再次获取?", MB_YESNO|MB_ICONSTOP)!=IDYES)
  281. return;
  282. }
  283. // m_List1.DeleteAllItems ();
  284. CString m_path=g_path3+"\\";
  285. if(g_bAllBranch&&m_branch!="")
  286. {
  287. CString domain=GetDomainFromBranch(m_branch);
  288. if(domain!=g_domain)
  289. {
  290. m_path+=domain+"\\";
  291. }
  292. //CString GetDomainFromBranch(CString branch)
  293. }
  294. m_path+=m_id;
  295. m_path +="\\";
  296. CStringArray m_patharray1;
  297. if(1)
  298. {
  299. m_path.MakeLower ();
  300. CStringArray dirarray;
  301. CString str;
  302. if(1)
  303. {
  304. using namespace helper_coffs;
  305. ffsco o;
  306. o.dirs(1);
  307. o.find(LPCSTR(m_path), LPCSTR("*.*"));
  308. ffsco::typeT coo;
  309. ffsco::typeT::iterator it;
  310. coo = o.co_dir();
  311. for (it = coo.begin();
  312. coo.end() != it;
  313. it ++)
  314. {
  315. str=(*it).c_str();
  316. if(FindArray(&dirarray, str)==-1)
  317. {
  318. dirarray.Add (str);
  319. }
  320. }
  321. }
  322. if(1)
  323. {
  324. for(int i=0; i<dirarray.GetSize (); i++)
  325. {
  326. using namespace helper_coffs;
  327. ffsco o;
  328. o.dirs(0);
  329. o.find(LPCSTR(dirarray.ElementAt (i)), LPCSTR("*.jpg"));
  330. ffsco::typeT coo;
  331. ffsco::typeT::iterator it;
  332. coo = o.co_file();
  333. for (it = coo.begin();
  334. coo.end() != it;
  335. it ++)
  336. {
  337. str=(*it).c_str();
  338. if(str.GetAt (str.ReverseFind ('\\')+1)=='s')continue;
  339. if(str.GetAt (str.ReverseFind ('\\')+1)=='m')continue;
  340. str.MakeLower ();
  341. m_patharray1.Add (str);
  342. }
  343. }
  344. }
  345. }
  346. CString str,temp;
  347. int oldcount=m_List1.GetItemCount ();
  348. for(int i=oldcount; i<(m_patharray1.GetSize ()+oldcount); i++)
  349. {
  350. str=m_patharray1.ElementAt (i-oldcount);
  351. temp.Empty ();
  352. if(str.Left (str.ReverseFind ('\\')+1)!=m_path)
  353. {
  354. temp=str.Left (str.ReverseFind ('\\')+1);
  355. temp= temp.Right (temp.GetLength ()-m_path.GetLength ());
  356. }
  357. str=str.Right (str.GetLength ()-str.ReverseFind ('\\')-1);
  358. str=temp+str.Left (str.GetLength ()-4);
  359. m_List1.InsertItem(i, str);
  360. m_List1.SetItemText(i, 1, "1");
  361. str=m_patharray1.ElementAt (i-oldcount);
  362. Image *img=NULL;
  363. ::LoadImageFromBuf (&img, str);
  364. if(img->GetWidth())
  365. {
  366. float area=(img->GetWidth()*img->GetHeight()*0.0254*0.0254)/(img->GetHorizontalResolution()*img->GetHorizontalResolution());
  367. str.Format ("%0.5f", area);
  368. m_List1.SetItemText(i, 2, str);
  369. delete img;
  370. }
  371. }
  372. if(m_patharray1.GetSize ()==0)
  373. AfxMessageBox("此单未导入设计片!", MB_ICONINFORMATION);
  374. UpdateZ();
  375. }
  376. void outsourcingDlg2::OnBTNdel()
  377. {
  378. // TODO: Add your control notification handler code here
  379. POSITION pos;
  380. pos=m_List1.GetFirstSelectedItemPosition();
  381. if(pos==NULL)
  382. {
  383. AfxMessageBox("请先选中您要删除的项目!", MB_ICONINFORMATION);
  384. return;
  385. }
  386. int iItem=m_List1.GetNextSelectedItem(pos);
  387. m_List1.DeleteItem (iItem);
  388. int count=m_List1.GetItemCount ();
  389. if(count==0)
  390. {
  391. UpdateZ();
  392. return;
  393. }
  394. if(iItem==count)
  395. iItem=0;
  396. m_List1.SetItemState (iItem, LVIS_SELECTED, LVIS_SELECTED);
  397. UpdateZ();
  398. }
  399. void outsourcingDlg2::UpdateZ()
  400. {
  401. CString str;
  402. str.Format ("全部相片名细:%d", m_List1.GetItemCount ());
  403. GetDlgItem(IDC_STATIC1)->SetWindowText( str);
  404. }
  405. void outsourcingDlg2::OnBTNdel2()
  406. {
  407. // TODO: Add your control notification handler code here
  408. if(m_List1.GetItemCount ())
  409. {
  410. if(AfxMessageBox("此单已有相片记录, 是否再次获取?", MB_YESNO|MB_ICONSTOP)!=IDYES)
  411. return;
  412. }
  413. int count=m_List1.GetItemCount ();
  414. #ifdef CHILD_VERSION
  415. CString filter="id='"+m_id+"' and name<>'入册' and name<>'入底'";
  416. #else
  417. CString filter="id='"+m_id+"' and kind<>'2' and name<>'入册' and name<>'入底'";
  418. #endif
  419. g_sendhead.code[0]=56;
  420. g_sendhead.tabcount=1;
  421. g_sendhead.bsql=0;
  422. g_pMainWnd->ProcessChatMessageRequest2(filter);if(g_bSendOK==0)return;
  423. CArray<CStringArray, CStringArray>List1array;
  424. DataToArray(&List1array);
  425. for(int i=0; i<List1array.GetSize(); i++)
  426. {
  427. m_List1.InsertItem(count+i, List1array.ElementAt(i).ElementAt(0));
  428. m_List1.SetItemText(count+i, 1, List1array.ElementAt(i).ElementAt(1));
  429. }
  430. UpdateZ();
  431. }
  432. void outsourcingDlg2::OnDestroy()
  433. {
  434. CDialog::OnDestroy();
  435. // TODO: Add your message handler code here
  436. if(g_bAllBranch)
  437. {
  438. g_pMainWnd->OnDisconnect();
  439. g_bBranchModify=0;g_branchip=g_branchname="";
  440. }
  441. }