outsourcingDlg2.cpp 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  1. // outsourcingDlg2.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "LYFZIPManage.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_WM_TIMER()
  48. ON_BN_CLICKED(IDC_BTNdel, OnBTNdel)
  49. //}}AFX_MSG_MAP
  50. END_MESSAGE_MAP()
  51. /////////////////////////////////////////////////////////////////////////////
  52. // outsourcingDlg2 diagnostics
  53. /////////////////////////////////////////////////////////////////////////////
  54. // outsourcingDlg2 message handlers
  55. BOOL outsourcingDlg2::PreTranslateMessage(MSG* pMsg)
  56. {
  57. // TODO: Add your specialized code here and/or call the base class
  58. if(pMsg->message==WM_LBUTTONDBLCLK)
  59. {//list1
  60. CPoint pt;
  61. CRect rc,rc2;
  62. ::GetCursorPos (&pt);
  63. m_List1.GetWindowRect (rc2);
  64. if(rc2.PtInRect (pt)==0) return CDialog::PreTranslateMessage(pMsg);
  65. pt.x-=rc2.left ;
  66. pt.y-=rc2.top ;
  67. int iItem=m_List1.GetItemCount ()-1;
  68. if(iItem<0)
  69. {
  70. m_List1.GetHeaderCtrl()->GetItemRect (0, rc);
  71. int hei=rc.Height ();
  72. rc.top +=hei;
  73. rc.bottom +=hei;
  74. if(rc.PtInRect (pt))
  75. {
  76. m_List1.InsertItem(m_List1.GetItemCount (), "");
  77. }
  78. m_List1.GetHeaderCtrl()->GetItemRect (1, rc);
  79. rc.top +=hei;
  80. rc.bottom +=hei;
  81. if(rc.PtInRect (pt))
  82. {
  83. m_List1.InsertItem(m_List1.GetItemCount (), "");
  84. }
  85. UpdateZ();
  86. }
  87. else
  88. {
  89. m_List1.GetSubItemRect( iItem, 0, LVIR_BOUNDS, rc);
  90. int hei=rc.Height ();
  91. rc.top +=hei;
  92. rc.bottom +=hei;
  93. if(rc.PtInRect (pt))
  94. {
  95. if(m_List1.GetItemText (iItem, 0).IsEmpty ())
  96. return CDialog::PreTranslateMessage(pMsg);
  97. m_List1.InsertItem(m_List1.GetItemCount (), "");
  98. UpdateZ();
  99. }
  100. }
  101. }
  102. return CDialog::PreTranslateMessage(pMsg);
  103. }
  104. void outsourcingDlg2::OnBUTclose()
  105. {
  106. // TODO: Add your control notification handler code here
  107. CDialog::OnCancel ();
  108. }
  109. void outsourcingDlg2::GetData()
  110. {
  111. // TODO: Add your control notification handler code here
  112. CString filter="id='"+m_id+"';";
  113. g_sendhead.code[0]=36;
  114. g_sendhead.code[1]=9;
  115. g_sendhead.tabcount=2;
  116. g_sendhead.bsql=0;
  117. g_pMainWnd->ProcessChatMessageRequest2(filter);if(g_bSendOK==0)return;
  118. DataToArray(&m_sparray,&g_List1array);
  119. m_List1.DeleteAllItems ();
  120. for(int i=0; i<m_sparray.GetSize (); i++)
  121. {
  122. m_List1.InsertItem(i, m_sparray.ElementAt (i).ElementAt (0));
  123. m_List1.SetItemText(i, 1, m_sparray.ElementAt (i).ElementAt (1));
  124. m_List1.SetItemText(i, 2, m_sparray.ElementAt (i).ElementAt (2));
  125. m_List1.SetItemText(i, 3, m_sparray.ElementAt (i).ElementAt (3));
  126. }
  127. UpdateZ();
  128. }
  129. BOOL outsourcingDlg2::OnInitDialog()
  130. {
  131. CDialog::OnInitDialog();
  132. // TODO: Add extra initialization here
  133. // Here we create the outbar control using the splitter as its parent
  134. // and setting its id to the first pane.
  135. m_List1.InitStyle();
  136. m_List1.InsertColumn(0,_T("相片名称"),LVCFMT_LEFT,360);
  137. m_List1.InsertColumn(1,_T("数量"),LVCFMT_LEFT,75);
  138. m_List1.InsertColumn(2,_T("是否发出"),LVCFMT_LEFT,135);
  139. m_List1.InsertColumn(3,_T("是否回来"),LVCFMT_LEFT,85);
  140. GetData();
  141. CenterWindow(g_pMainWnd);
  142. return TRUE; // return TRUE unless you set the focus to a control
  143. // EXCEPTION: OCX Property Pages should return FALSE
  144. }
  145. void outsourcingDlg2::OnOK()
  146. {
  147. // TODO: Add extra validation here
  148. m_sparray.RemoveAll ();
  149. m_sparray.SetSize(m_List1.GetItemCount ());
  150. int realcount=0;
  151. CString str;
  152. for(int i=0; i<m_List1.GetItemCount (); i++)
  153. {
  154. str=m_List1.GetItemText (i, 0);
  155. str.TrimLeft (); str.TrimRight ();
  156. if(str.IsEmpty ())continue;
  157. m_sparray.ElementAt (realcount).RemoveAll ();
  158. m_sparray.ElementAt (realcount).Add ( m_id );
  159. m_sparray.ElementAt (realcount).Add (m_List1.GetItemText (i, 0) );
  160. m_sparray.ElementAt (realcount).Add (m_List1.GetItemText (i, 1) );
  161. m_sparray.ElementAt (realcount).Add (m_List1.GetItemText (i, 2) );
  162. m_sparray.ElementAt (realcount).Add (m_List1.GetItemText (i, 3) );
  163. realcount++;
  164. }
  165. m_sparray.SetSize(realcount);
  166. if(m_sparray.GetSize ()==0)
  167. {
  168. m_sparray.SetSize(1);
  169. m_sparray.ElementAt (0).Add ( m_id );
  170. }
  171. CMemFile memfile;
  172. CArchive ar(&memfile, CArchive::store);
  173. for(int ii=0; ii<m_sparray.GetSize (); ii++)
  174. {
  175. m_sparray.ElementAt (ii).Serialize (ar);
  176. }
  177. ar.Close();
  178. int length=memfile.GetLength ();
  179. BYTE *pData = memfile.Detach();
  180. int size=m_sparray.GetSize ();
  181. BYTE *pData2=new BYTE[length+sizeof(int)];
  182. memcpy(pData2, pData, length);
  183. memcpy(pData2+length, &size, sizeof(int));
  184. delete []pData;
  185. length+=sizeof(int);
  186. g_nSendCode=13;
  187. g_pMainWnd->ProcessChatMessageRequest2(pData2, length);
  188. g_nSendCode=0;
  189. delete []pData2;
  190. if(g_bSendOK==0)return;
  191. AfxMessageBox("保存成功!", MB_ICONINFORMATION);
  192. CDialog::OnOK();
  193. }
  194. void outsourcingDlg2::OnButton1()
  195. {
  196. // TODO: Add your control notification handler code here
  197. SelProvider dlg;
  198. if(dlg.DoModal ()!=IDOK)return;
  199. for(int i=0; i<m_List1.GetItemCount (); i++)
  200. {
  201. m_List1.SetItemText (i, 2, dlg.m_provider);
  202. }
  203. }
  204. void outsourcingDlg2::OnButton3()
  205. {
  206. // TODO: Add your control notification handler code here
  207. for(int i=0; i<m_List1.GetItemCount (); i++)
  208. {
  209. m_List1.SetItemText (i, 2, "");
  210. }
  211. }
  212. void outsourcingDlg2::OnButton2()
  213. {
  214. // TODO: Add your control notification handler code here
  215. for(int i=0; i<m_List1.GetItemCount (); i++)
  216. {
  217. m_List1.SetItemText (i, 3, "OK");
  218. }
  219. }
  220. void outsourcingDlg2::OnButton4()
  221. {
  222. // TODO: Add your control notification handler code here
  223. for(int i=0; i<m_List1.GetItemCount (); i++)
  224. {
  225. m_List1.SetItemText (i, 3, "");
  226. }
  227. }
  228. void outsourcingDlg2::OnBUTget()
  229. {
  230. // TODO: Add your control notification handler code here
  231. if(m_List1.GetItemCount ())
  232. {
  233. if(AfxMessageBox("此单已有相片记录, 再次获取相片将导致原发片记录丢失, 是否继续?", MB_YESNO|MB_ICONSTOP)!=IDYES)
  234. return;
  235. }
  236. m_List1.DeleteAllItems ();
  237. CString m_path=g_path3+"\\";
  238. m_path+=m_id;
  239. m_path +="\\";
  240. CStringArray m_patharray1;
  241. if(1)
  242. {
  243. m_path.MakeLower ();
  244. CStringArray dirarray;
  245. CString str;
  246. if(1)
  247. {
  248. using namespace helper_coffs;
  249. ffsco o;
  250. o.dirs(1);
  251. o.find(LPCSTR(m_path), LPCSTR("*.*"));
  252. ffsco::typeT coo;
  253. ffsco::typeT::iterator it;
  254. coo = o.co_dir();
  255. for (it = coo.begin();
  256. coo.end() != it;
  257. it ++)
  258. {
  259. str=(*it).c_str();
  260. if(FindArray(&dirarray, str)==-1)
  261. {
  262. dirarray.Add (str);
  263. }
  264. }
  265. }
  266. if(1)
  267. {
  268. for(int i=0; i<dirarray.GetSize (); i++)
  269. {
  270. using namespace helper_coffs;
  271. ffsco o;
  272. o.dirs(0);
  273. o.find(LPCSTR(dirarray.ElementAt (i)), LPCSTR("*.jpg"));
  274. ffsco::typeT coo;
  275. ffsco::typeT::iterator it;
  276. coo = o.co_file();
  277. for (it = coo.begin();
  278. coo.end() != it;
  279. it ++)
  280. {
  281. str=(*it).c_str();
  282. if(str.GetAt (str.ReverseFind ('\\')+1)=='s')continue;
  283. str.MakeLower ();
  284. m_patharray1.Add (str);
  285. }
  286. }
  287. }
  288. }
  289. CString str,temp;
  290. for(int i=0; i<m_patharray1.GetSize (); i++)
  291. {
  292. str=m_patharray1.ElementAt (i);
  293. temp.Empty ();
  294. if(str.Left (str.ReverseFind ('\\')+1)!=m_path)
  295. {
  296. temp=str.Left (str.ReverseFind ('\\')+1);
  297. temp= temp.Right (temp.GetLength ()-m_path.GetLength ());
  298. }
  299. str=str.Right (str.GetLength ()-str.ReverseFind ('\\')-1);
  300. str=temp+str.Left (str.GetLength ()-4);
  301. m_List1.InsertItem(i, str);
  302. m_List1.SetItemText(i, 1, "1");
  303. }
  304. if(m_patharray1.GetSize ()==0)
  305. AfxMessageBox("此单未导入设计片!", MB_ICONINFORMATION);
  306. UpdateZ();
  307. }
  308. void outsourcingDlg2::OnBTNdel()
  309. {
  310. // TODO: Add your control notification handler code here
  311. POSITION pos;
  312. pos=m_List1.GetFirstSelectedItemPosition();
  313. if(pos==NULL)
  314. {
  315. AfxMessageBox("请先选中您要删除的项目!", MB_ICONINFORMATION);
  316. return;
  317. }
  318. int iItem=m_List1.GetNextSelectedItem(pos);
  319. m_List1.DeleteItem (iItem);
  320. int count=m_List1.GetItemCount ();
  321. if(count==0)
  322. {
  323. UpdateZ();
  324. return;
  325. }
  326. if(iItem==count)
  327. iItem=0;
  328. m_List1.SetItemState (iItem, LVIS_SELECTED, LVIS_SELECTED);
  329. UpdateZ();
  330. }
  331. void outsourcingDlg2::UpdateZ()
  332. {
  333. CString str;
  334. str.Format ("全部相片名细:%d", m_List1.GetItemCount ());
  335. GetDlgItem(IDC_STATIC1)->SetWindowText( str);
  336. }