123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517 |
- // outsourcingDlg2.cpp : implementation file
- //
- #include "stdafx.h"
- #include "ylgl.h"
- #include "outsourcingDlg2.h"
- #include "SelProvider.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // outsourcingDlg2
- outsourcingDlg2::outsourcingDlg2(CWnd* pParent /*=NULL*/)
- : CDialog(outsourcingDlg2::IDD)
- {
- //{{AFX_DATA_INIT(outsourcingDlg2)IDC_COMBOid
- m_name1 = _T("");
- m_name2 = _T("");
- m_id = _T("");
- m_money1 = _T("");
- m_money2 = _T("");
- m_money3 = _T("");
- //}}AFX_DATA_INIT
- }
- void outsourcingDlg2::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(outsourcingDlg2)
- DDX_Control(pDX, IDC_LIST1, m_List1);
- DDX_Text(pDX, IDC_EDITname1, m_name1);
- DDX_Text(pDX, IDC_EDITname2, m_name2);
- DDX_Text(pDX, IDC_EDITid2, m_id);
- DDX_Text(pDX, IDC_EDITmoney1, m_money1);
- DDX_Text(pDX, IDC_EDITmoney2, m_money2);
- DDX_Text(pDX, IDC_EDITmoney3, m_money3);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(outsourcingDlg2, CDialog)
- //{{AFX_MSG_MAP(outsourcingDlg2)
- ON_BN_CLICKED(IDC_BUTclose, OnBUTclose)
- ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
- ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
- ON_BN_CLICKED(IDC_BUTget, OnBUTget)
- ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
- ON_BN_CLICKED(IDC_BUTTON4, OnButton4)
- ON_BN_CLICKED(IDC_BTNdel, OnBTNdel)
- ON_BN_CLICKED(IDC_BTNdel2, OnBTNdel2)
- ON_WM_TIMER()
- ON_WM_DESTROY()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // outsourcingDlg2 diagnostics
- /////////////////////////////////////////////////////////////////////////////
- // outsourcingDlg2 message handlers
- BOOL outsourcingDlg2::PreTranslateMessage(MSG* pMsg)
- {
- // TODO: Add your specialized code here and/or call the base class
- if(pMsg->message==WM_LBUTTONDBLCLK)
- {//list1
- CPoint pt;
- CRect rc,rc2;
- ::GetCursorPos (&pt);
- m_List1.GetWindowRect (rc2);
- if(rc2.PtInRect (pt)==0) return CDialog::PreTranslateMessage(pMsg);
- pt.x-=rc2.left ;
- pt.y-=rc2.top ;
- int iItem=m_List1.GetItemCount ()-1;
- if(iItem<0)
- {
- m_List1.GetHeaderCtrl()->GetItemRect (0, rc);
- int hei=rc.Height ();
- rc.top +=hei;
- rc.bottom +=hei;
- if(rc.PtInRect (pt))
- {
- m_List1.InsertItem(m_List1.GetItemCount (), "");
- }
- m_List1.GetHeaderCtrl()->GetItemRect (1, rc);
- rc.top +=hei;
- rc.bottom +=hei;
- if(rc.PtInRect (pt))
- {
- m_List1.InsertItem(m_List1.GetItemCount (), "");
- }
- UpdateZ();
- }
- else
- {
- m_List1.GetSubItemRect( iItem, 0, LVIR_BOUNDS, rc);
- int hei=rc.Height ();
- rc.top +=hei;
- rc.bottom +=hei;
- if(rc.PtInRect (pt))
- {
- if(m_List1.GetItemText (iItem, 0).IsEmpty ())
- return CDialog::PreTranslateMessage(pMsg);
- m_List1.InsertItem(m_List1.GetItemCount (), "");
- UpdateZ();
- }
- }
- }
- return CDialog::PreTranslateMessage(pMsg);
- }
- void outsourcingDlg2::OnBUTclose() // 关闭按钮;
- {
- // TODO: Add your control notification handler code here
- CDialog::OnCancel ();
- }
- void outsourcingDlg2::GetData()
- {
- // TODO: Add your control notification handler code here
- if(g_bAllBranch==0)
- {
- CString filter="id='"+m_id+"';";
- g_sendhead.code[0]=36;
- g_sendhead.code[1]=9;
- g_sendhead.tabcount=2;
- g_sendhead.bsql=0;
- g_pMainWnd->ProcessChatMessageRequest2(filter);if(g_bSendOK==0)return;
- DataToArray(&m_sparray,&g_List1array);
- }
- else
- {
- g_pMainWnd->OnDisconnect();
- g_branchip=GetIP(m_branch);
- g_pMainWnd->OnDisconnect();
- g_branchname=m_branch;
- g_bBranchModify=1;
- CString filter="id='"+m_id+"';";
- g_sendhead.code[0]=36;
- g_sendhead.code[1]=9;
- g_sendhead.tabcount=2;
- g_sendhead.bsql=0;
- g_pMainWnd->ProcessChatMessageRequest2(filter);if(g_bSendOK==0)return;
- DataToArray(&m_sparray,&g_List1array);
- }
- m_List1.DeleteAllItems ();
- for(int i=0; i<m_sparray.GetSize (); i++)
- {
- m_List1.InsertItem(i, m_sparray.ElementAt (i).ElementAt (0));
- m_List1.SetItemText(i, 1, m_sparray.ElementAt (i).ElementAt (1));
- m_List1.SetItemText(i, 2, m_sparray.ElementAt (i).ElementAt (2));
- m_List1.SetItemText(i, 3, m_sparray.ElementAt (i).ElementAt (3));
- m_List1.SetItemText(i, 4, m_sparray.ElementAt (i).ElementAt (4));
- #if 0 // Jeff.delete;
- m_List1.SetItemText(i, 5, m_sparray.ElementAt (i).ElementAt (5));
- m_List1.SetItemText(i, 6, m_sparray.ElementAt (i).ElementAt (6));
- #else
- m_List1.SetItemText(i, 5, m_sparray.ElementAt (i).ElementAt (5));
- m_List1.SetItemText(i, 6, m_sparray.ElementAt (i).ElementAt (6));
- m_List1.SetItemText(i, 7, m_sparray.ElementAt (i).ElementAt (7));
- m_List1.SetItemText(i, 8, m_sparray.ElementAt (i).ElementAt (8));
- #endif
- }
- UpdateZ();
- }
- extern BOOL CALLBACK EnumChildProc2(HWND hwnd,LPARAM lParam);
- BOOL outsourcingDlg2::OnInitDialog()
- {
- CDialog::OnInitDialog();
- CRect rc2;
- GetWindowRect(rc2);
- ::MoveWindow(m_hWnd,g_rc.left,g_rc.top,g_rc.Width(),g_rc.Height(),TRUE);
- g_WidthScale2 = (float)g_rc.Width()/(float)rc2.Width(); // new/Old
- g_HeightScale2 = (float)g_rc.Height()/(float)rc2.Height();
- EnumChildWindows(m_hWnd,(WNDENUMPROC)EnumChildProc2,0);
- #ifdef CHILD_VERSION
- GetDlgItem(IDC_STATIC2)->SetWindowText("家长姓名:");
- GetDlgItem(IDC_STATIC4)->SetWindowText("宝宝姓名:");
- #endif
- // TODO: Add extra initialization here
- // Here we create the outbar control using the splitter as its parent
- // and setting its id to the first pane.
- m_List1.InitStyle();
- m_List1.InsertColumn(0,_T("相片名称"),LVCFMT_LEFT,300);
- m_List1.InsertColumn(1,_T("数量"),LVCFMT_LEFT,60);
- m_List1.InsertColumn(2,_T("面积"),LVCFMT_LEFT,80);
- m_List1.InsertColumn(3,_T("是否发出"),LVCFMT_LEFT,115);
- m_List1.InsertColumn(4,_T("发出日期"),LVCFMT_LEFT,90);
- #if 1// Jeff。添加 返工,返工日期;(与发件取片一样);
- m_List1.InsertColumn(5,_T("返工"),LVCFMT_LEFT,90);
- m_List1.InsertColumn(6,_T("返工日期"),LVCFMT_LEFT,90);
- m_List1.InsertColumn(7,_T("是否回来"),LVCFMT_LEFT,90);
- m_List1.InsertColumn(8,_T("回来日期"),LVCFMT_LEFT,90);
- #else
- m_List1.InsertColumn(5,_T("是否回来"),LVCFMT_LEFT,90);
- m_List1.InsertColumn(6,_T("回来日期"),LVCFMT_LEFT,90);
- #endif
- GetData();
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void outsourcingDlg2::OnOK() // 保存按钮;
- {
- // TODO: Add extra validation here
- m_sparray.RemoveAll ();
- m_sparray.SetSize(m_List1.GetItemCount ());
- int realcount=0;
- CString str;
- for(int i=0; i<m_List1.GetItemCount (); i++)
- {
- str=m_List1.GetItemText (i, 0);
- str.TrimLeft (); str.TrimRight ();
- if(str.IsEmpty ())continue;
- m_sparray.ElementAt (realcount).RemoveAll ();
- m_sparray.ElementAt (realcount).Add ( m_id );
- m_sparray.ElementAt (realcount).Add (m_List1.GetItemText (i, 0) );
- m_sparray.ElementAt (realcount).Add (m_List1.GetItemText (i, 1) );
- m_sparray.ElementAt (realcount).Add (m_List1.GetItemText (i, 2) );
- m_sparray.ElementAt (realcount).Add (m_List1.GetItemText (i, 3) );
- m_sparray.ElementAt (realcount).Add (m_List1.GetItemText (i, 4) );
- #if 0
- m_sparray.ElementAt (realcount).Add (m_List1.GetItemText (i, 5) );
- m_sparray.ElementAt (realcount).Add (m_List1.GetItemText (i, 6) );
- #else
- m_sparray.ElementAt (realcount).Add (m_List1.GetItemText (i, 5) ); // 返工;
- m_sparray.ElementAt (realcount).Add (m_List1.GetItemText (i, 6) ); // 返工日期;
- m_sparray.ElementAt (realcount).Add (m_List1.GetItemText (i, 7) ); // 取回状态;
- m_sparray.ElementAt (realcount).Add (m_List1.GetItemText (i, 8) ); // 取回日期;
- #endif
- realcount++;
- }
- m_sparray.SetSize(realcount);
- if(m_sparray.GetSize()==0)
- {
- m_sparray.SetSize(1);
- m_sparray.ElementAt(0).Add( m_id );
- }
- CMemFile memfile;
- CArchive ar(&memfile, CArchive::store);
- for(int ii=0; ii<m_sparray.GetSize(); ii++)
- {
- m_sparray.ElementAt(ii).Serialize(ar);
- }
- ar.Close();
- int length = memfile.GetLength ();
- BYTE *pData = memfile.Detach();
- int size = m_sparray.GetSize ();
- BYTE *pData2 = new BYTE[length+sizeof(int)];
- memcpy(pData2, pData, length);
- memcpy(pData2+length, &size, sizeof(int));
- delete []pData;
- length+=sizeof(int);
- g_nSendCode=13;
- g_pMainWnd->ProcessChatMessageRequest2(pData2, length);
- g_nSendCode=0;
- delete []pData2;
- if(g_bSendOK==0)return;
- AfxMessageBox("保存成功!", MB_ICONINFORMATION);
- CDialog::OnOK();
- }
- void outsourcingDlg2::OnButton1() // 全部发出按钮;
- {
- // TODO: Add your control notification handler code here
- SelProvider dlg;
- if(dlg.DoModal ()!=IDOK)return;
- for(int i=0; i<m_List1.GetItemCount (); i++)
- {
- m_List1.SetItemText (i, 3, dlg.m_provider);
- m_List1.SetItemText (i, 4, g_date);
- }
- }
- void outsourcingDlg2::OnButton3() // 全部发出-重置按钮;
- {
- // TODO: Add your control notification handler code here
- for(int i=0; i<m_List1.GetItemCount (); i++)
- {
- m_List1.SetItemText (i, 3, "");
- m_List1.SetItemText (i, 4, "");
- m_List1.SetItemText (i, 5, "");
- m_List1.SetItemText (i, 6, "");
- #if 1
- m_List1.SetItemText(i,7,"");
- m_List1.SetItemText(i,8,"");
- #endif
- }
- }
- void outsourcingDlg2::OnButton2() // 全部回来按钮;
- {
- // TODO: Add your control notification handler code here
- for(int i=0; i<m_List1.GetItemCount(); i++)
- {
- #if 0
- m_List1.SetItemText (i, 5, "OK");
- m_List1.SetItemText (i, 6, g_date);
- #else
- m_List1.SetItemText(i, 7, "OK");
- m_List1.SetItemText(i, 8, g_date);
- #endif
- }
- }
- void outsourcingDlg2::OnButton4() // 全部回来-重置按钮;
- {
- // TODO: Add your control notification handler code here
- for(int i=0; i<m_List1.GetItemCount (); i++)
- {
- #if 0
- m_List1.SetItemText (i, 5, "");
- m_List1.SetItemText (i, 6, "");
- #else
- m_List1.SetItemText(i, 7, "");
- m_List1.SetItemText(i, 8, "");
- #endif
- }
- }
- extern CString g_domain;
- void outsourcingDlg2::OnBUTget() // 从设计;
- {
- // TODO: Add your control notification handler code here
- if(m_List1.GetItemCount ())
- {
- if(AfxMessageBox("此单已有相片记录, 是否再次获取?", MB_YESNO|MB_ICONSTOP)!=IDYES)
- return;
- }
- // m_List1.DeleteAllItems ();
- CString m_path=g_path3+"\\";
- if(g_bAllBranch&&m_branch!="")
- {
- CString domain=GetDomainFromBranch(m_branch);
- if(domain!=g_domain)
- {
- m_path+=domain+"\\";
- }
- //CString GetDomainFromBranch(CString branch)
- }
- m_path+=m_id;
- m_path +="\\";
- CStringArray m_patharray1;
- if(1)
- {
- m_path.MakeLower ();
- CStringArray dirarray;
- CString str;
- if(1)
- {
- using namespace helper_coffs;
- ffsco o;
- o.dirs(1);
- o.find(LPCSTR(m_path), LPCSTR("*.*"));
- ffsco::typeT coo;
- ffsco::typeT::iterator it;
- coo = o.co_dir();
- for (it = coo.begin();coo.end() != it;it ++)
- {
- str=(*it).c_str();
- if(FindArray(&dirarray, str)==-1)
- {
- dirarray.Add (str);
- }
- }
- }
- if(1)
- {
- for(int i=0; i<dirarray.GetSize (); i++)
- {
- using namespace helper_coffs;
- ffsco o;
- o.dirs(0);
- o.find(LPCSTR(dirarray.ElementAt (i)), LPCSTR("*.jpg"));
- ffsco::typeT coo;
- ffsco::typeT::iterator it;
- coo = o.co_file();
- for (it = coo.begin();coo.end() != it;it ++)
- {
- str=(*it).c_str();
- if(str.GetAt (str.ReverseFind ('\\')+1)=='s')continue;
- if(str.GetAt (str.ReverseFind ('\\')+1)=='m')continue;
- str.MakeLower ();
- m_patharray1.Add (str);
- }
- }
- }
- }
- CString str,temp;
- int oldcount=m_List1.GetItemCount ();
- for(int i=oldcount; i<(m_patharray1.GetSize ()+oldcount); i++)
- {
- str=m_patharray1.ElementAt (i-oldcount);
- temp.Empty ();
- if(str.Left (str.ReverseFind ('\\')+1)!=m_path)
- {
- temp=str.Left (str.ReverseFind ('\\')+1);
- temp= temp.Right (temp.GetLength ()-m_path.GetLength ());
- }
- str=str.Right (str.GetLength ()-str.ReverseFind ('\\')-1);
- str=temp+str.Left (str.GetLength ()-4);
- m_List1.InsertItem(i, str);
- m_List1.SetItemText(i, 1, "1");
- str=m_patharray1.ElementAt (i-oldcount);
- Image *img=NULL;
- ::LoadImageFromBuf (&img, str);
- if(img->GetWidth())
- {
- float area=(img->GetWidth()*img->GetHeight()*0.0254*0.0254)/(img->GetHorizontalResolution()*img->GetHorizontalResolution());
- str.Format ("%0.5f", area);
- m_List1.SetItemText(i, 2, str);
- delete img;
- }
- }
- if(m_patharray1.GetSize ()==0)
- AfxMessageBox("此单未导入设计片!", MB_ICONINFORMATION);
- UpdateZ();
- }
- void outsourcingDlg2::OnBTNdel() // 删除按钮;
- {
- // TODO: Add your control notification handler code here
- POSITION pos;
- pos=m_List1.GetFirstSelectedItemPosition();
- if(pos==NULL)
- {
- AfxMessageBox("请先选中您要删除的项目!", MB_ICONINFORMATION);
- return;
- }
- int iItem=m_List1.GetNextSelectedItem(pos);
- m_List1.DeleteItem (iItem);
- int count=m_List1.GetItemCount ();
- if(count==0)
- {
- UpdateZ();
- return;
- }
- if(iItem==count)
- iItem=0;
- m_List1.SetItemState (iItem, LVIS_SELECTED, LVIS_SELECTED);
- UpdateZ();
- }
- void outsourcingDlg2::UpdateZ()
- {
- CString str;
- str.Format ("全部相片名细:%d", m_List1.GetItemCount());
- GetDlgItem(IDC_STATIC1)->SetWindowText( str);
- }
- void outsourcingDlg2::OnBTNdel2() // 从产品中获取;
- {
- // TODO: Add your control notification handler code here
- if(m_List1.GetItemCount ())
- {
- if(AfxMessageBox("此单已有相片记录, 是否再次获取?", MB_YESNO|MB_ICONSTOP)!=IDYES)
- return;
- }
- int count = m_List1.GetItemCount();
- #ifdef CHILD_VERSION
- CString filter="id='"+m_id+"' and name<>'入册' and name<>'入底'";
- #else
- CString filter="id='"+m_id+"' and kind<>'2' and name<>'入册' and name<>'入底'";
- #endif
- g_sendhead.code[0]=56; // Table is dindansp;
- g_sendhead.tabcount=1;
- g_sendhead.bsql=0;
- g_pMainWnd->ProcessChatMessageRequest2(filter);if(g_bSendOK==0)return;
- CArray<CStringArray, CStringArray>List1array;
- DataToArray(&List1array);
- for(int i=0; i<List1array.GetSize(); i++)
- {
- m_List1.InsertItem(count+i, List1array.ElementAt(i).ElementAt(0)); // 相片名称;
- m_List1.SetItemText(count+i, 1, List1array.ElementAt(i).ElementAt(1)); // 相片数量;
- //printf("Jeff:%s,%s\n\n",List1array.ElementAt(i).ElementAt(0),List1array.ElementAt(i).ElementAt(1));
- }
- UpdateZ();
- }
- void outsourcingDlg2::OnDestroy()
- {
- CDialog::OnDestroy();
- // TODO: Add your message handler code here
- if(g_bAllBranch)
- {
- g_pMainWnd->OnDisconnect();
- g_bBranchModify=0;g_branchip=g_branchname="";
- }
- }
|