123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363 |
- // outsourcingDlg2.cpp : implementation file
- //
- #include "stdafx.h"
- #include "LYFZIPManage.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_WM_TIMER()
- ON_BN_CLICKED(IDC_BTNdel, OnBTNdel)
- //}}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
- 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));
- }
- UpdateZ();
- }
- BOOL outsourcingDlg2::OnInitDialog()
- {
- CDialog::OnInitDialog();
- // 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,360);
- m_List1.InsertColumn(1,_T("数量"),LVCFMT_LEFT,75);
- m_List1.InsertColumn(2,_T("是否发出"),LVCFMT_LEFT,135);
- m_List1.InsertColumn(3,_T("是否回来"),LVCFMT_LEFT,85);
- GetData();
- CenterWindow(g_pMainWnd);
- 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) );
- 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, 2, dlg.m_provider);
- }
- }
- void outsourcingDlg2::OnButton3()
- {
- // TODO: Add your control notification handler code here
- for(int i=0; i<m_List1.GetItemCount (); i++)
- {
- m_List1.SetItemText (i, 2, "");
- }
- }
- void outsourcingDlg2::OnButton2()
- {
- // TODO: Add your control notification handler code here
- for(int i=0; i<m_List1.GetItemCount (); i++)
- {
- m_List1.SetItemText (i, 3, "OK");
- }
- }
- void outsourcingDlg2::OnButton4()
- {
- // TODO: Add your control notification handler code here
- for(int i=0; i<m_List1.GetItemCount (); i++)
- {
- m_List1.SetItemText (i, 3, "");
- }
- }
- 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+"\\";
- 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;
- str.MakeLower ();
- m_patharray1.Add (str);
- }
- }
- }
- }
- CString str,temp;
- for(int i=0; i<m_patharray1.GetSize (); i++)
- {
- str=m_patharray1.ElementAt (i);
- 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");
- }
- 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);
- }
|