| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254 |
- // SetLoginBan.cpp : implementation file
- //
- #include "stdafx.h"
- #include "ylgl.h"
- #include "SetLoginBan.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // SetLoginBan dialog
- SetLoginBan::SetLoginBan(CWnd* pParent /*=NULL*/)
- : CDialog(SetLoginBan::IDD, pParent)
- {
- //{{AFX_DATA_INIT(SetLoginBan)
- // NOTE: the ClassWizard will add member initialization here
- //}}AFX_DATA_INIT
- m_pos=0;
- }
- void SetLoginBan::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(SetLoginBan)
- DDX_Control(pDX, IDC_LIST1, m_List1);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(SetLoginBan, CDialog)
- //{{AFX_MSG_MAP(SetLoginBan)
- ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
- ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
- ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
- ON_BN_CLICKED(IDC_BUTTON4, OnButton4)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // SetLoginBan message handlers
- BOOL SetLoginBan::OnInitDialog()
- {
- CDialog::OnInitDialog();
-
- // TODO: Add extra initialization here
- g_sendhead.bsql=0;
- g_sendhead.code[0]=97;
- g_sendhead.tabcount=1;
- g_pMainWnd->ProcessChatMessageRequest2(2);if(g_bSendOK==0)return false;
- DataToArray(&g_List1array);
- m_List1.InitStyle();
- m_List1.InsertColumn(0,_T("姓名"),LVCFMT_LEFT,100);
- m_List1.InsertColumn(1,_T("星期日"),LVCFMT_LEFT,100);
- m_List1.InsertColumn(2,_T("星期一"),LVCFMT_LEFT,100);
- m_List1.InsertColumn(3,_T("星期二"),LVCFMT_LEFT,100);
- m_List1.InsertColumn(4,_T("星期三"),LVCFMT_LEFT,100);
- m_List1.InsertColumn(5,_T("星期四"),LVCFMT_LEFT,100);
- m_List1.InsertColumn(6,_T("星期五"),LVCFMT_LEFT,100);
- m_List1.InsertColumn(7,_T("星期六"),LVCFMT_LEFT,100);
- GetTimeRange();
- CenterWindow();
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void SetLoginBan::GetTimeRange()
- {
- CTime tm(atoi(g_date.Mid (0,4)),atoi(g_date.Mid (5,2)),atoi(g_date.Mid (8,2)),0,0,0);//=CTime::GetCurrentTime ();
-
- if(m_pos)
- {
- CTimeSpan sp(abs(m_pos)*7, 0, 0, 0);
- if(m_pos>0)
- tm+=sp;
- else
- tm-=sp;
- }
- int nDayWeek = tm.GetDayOfWeek()-1;
- int days1=nDayWeek;
- int days2=6-nDayWeek;
- CTime tm2,tm3;
- CTimeSpan sp(days1, 0, 0, 0);
- tm2=tm-sp;
- CTimeSpan sp2(days2, 0, 0, 0);
- tm3=tm+sp2;
- CString str;
- str.Format ("时间段:%04d-%02d-%02d 至 %04d-%02d-%02d", tm2.GetYear (), tm2.GetMonth (), tm2.GetDay (), tm3.GetYear (), tm3.GetMonth (), tm3.GetDay () );
- SetDlgItemText(IDC_STATIC1, str);
- m_scurdate.Format ("%04d-%02d-%02d", tm2.GetYear (), tm2.GetMonth (), tm2.GetDay () );
- ShowLoginData();
- }
- void SetLoginBan::OnButton1()
- {
- // TODO: Add your control notification handler code here
- m_pos--;
- GetTimeRange();
- }
- void SetLoginBan::OnButton2()
- {
- // TODO: Add your control notification handler code here
- m_pos++;
- GetTimeRange();
- }
- void SetLoginBan::ShowLoginData()
- {//m_scurdate
- CString filter="weekname='"+m_scurdate+"'";
- g_sendhead.code[0]=107;
- g_sendhead.tabcount=1;
- g_sendhead.bsql=0;
- g_pMainWnd->ProcessChatMessageRequest2(filter);if(g_bSendOK==0)return;
- CArray<CStringArray, CStringArray>List1array;
- DataToArray(&List1array);
- m_List1.DeleteAllItems ();
-
- for(int i=0; i<List1array.GetSize (); i++)
- {
- m_List1.InsertItem(i, List1array.ElementAt (i).ElementAt (0));
- m_List1.SetItemText(i, 1, List1array.ElementAt (i).ElementAt (1));
- m_List1.SetItemText(i, 2, List1array.ElementAt (i).ElementAt (2));
- m_List1.SetItemText(i, 3, List1array.ElementAt (i).ElementAt (3));
- m_List1.SetItemText(i, 4, List1array.ElementAt (i).ElementAt (4));
- m_List1.SetItemText(i, 5, List1array.ElementAt (i).ElementAt (5));
- m_List1.SetItemText(i, 6, List1array.ElementAt (i).ElementAt (6));
- m_List1.SetItemText(i, 7, List1array.ElementAt (i).ElementAt (7));
- }
- }
- void SetLoginBan::OnOK()
- {
- // TODO: Add extra validation here
- CStringArray array;
- array.Add (m_scurdate);
- for(int i=0; i<m_List1.GetItemCount (); i++)
- {
- array.Add (m_List1.GetItemText (i, 0));
- array.Add (m_List1.GetItemText (i, 1));
- array.Add (m_List1.GetItemText (i, 2));
- array.Add (m_List1.GetItemText (i, 3));
- array.Add (m_List1.GetItemText (i, 4));
- array.Add (m_List1.GetItemText (i, 5));
- array.Add (m_List1.GetItemText (i, 6));
- array.Add (m_List1.GetItemText (i, 7));
- }
- CMemFile memfile;
- CArchive ar(&memfile, CArchive::store);
- array.Serialize (ar);
- ar.Close();
- int length=memfile.GetLength ();
- BYTE *pData = memfile.Detach();
- g_nSendCode=23;
- g_pMainWnd->ProcessChatMessageRequest2(pData, length);
- g_nSendCode=0;
- delete []pData;
- if(g_bSendOK==0)return;
-
- AfxMessageBox("保存成功!", MB_ICONINFORMATION);
- }
- void SetLoginBan::OnButton3()
- {
- // TODO: Add your control notification handler code here
- CFileDialog fdlg(false, NULL,"ban1", OFN_ALLOWMULTISELECT,"排班文件(*.ban)|*.ban||");
- if(fdlg.DoModal ()!=IDOK)return;
- CStringArray array;
- for(int i=0; i<m_List1.GetItemCount (); i++)
- {
- array.Add (m_List1.GetItemText (i, 0));
- array.Add (m_List1.GetItemText (i, 1));
- array.Add (m_List1.GetItemText (i, 2));
- array.Add (m_List1.GetItemText (i, 3));
- array.Add (m_List1.GetItemText (i, 4));
- array.Add (m_List1.GetItemText (i, 5));
- array.Add (m_List1.GetItemText (i, 6));
- array.Add (m_List1.GetItemText (i, 7));
- }
- CMemFile memfile;
- CArchive ar(&memfile, CArchive::store);
- array.Serialize (ar);
- ar.Close();
- int length=memfile.GetLength ();
- BYTE *pData = memfile.Detach();
- CString path=fdlg.GetPathName ();
- path+=".ban";
- CFile fp;
- fp.Open (path, CFile::modeCreate|CFile::modeWrite);
- fp.Write (pData, length);
- fp.Close ();
- delete []pData;
- AfxMessageBox("保存成功!", MB_ICONINFORMATION);
- }
- void SetLoginBan::OnButton4()
- {
- // TODO: Add your control notification handler code here
- CFileDialog fdlg(true, NULL,"", OFN_ALLOWMULTISELECT,"排班文件(*.ban)|*.ban||");
- if(fdlg.DoModal ()!=IDOK)return;
- CString path=fdlg.GetPathName ();
- CFile fp;
- fp.Open (path, CFile::modeRead);
- DWORD count=fp.GetLength ();
- BYTE *pData=new BYTE [count];
- fp.Read (pData, count);
- fp.Close ();
-
- CStringArray array;
- CMemFile memfile;
- memfile.Attach (pData, count);
- CArchive ar(&memfile, CArchive::load);
- array.Serialize (ar);
- ar.Close();
- memfile.Detach ();
- delete []pData;
- CString name;
- for(int i=0; i<m_List1.GetItemCount (); i++)
- {
- name=m_List1.GetItemText (i, 0);
- for(int j=0; j<array.GetSize (); j+=8)
- {
- if(name==array.ElementAt (j))
- {
- m_List1.SetItemText (i, 1, array.ElementAt (j+1));
- m_List1.SetItemText (i, 2, array.ElementAt (j+2));
- m_List1.SetItemText (i, 3, array.ElementAt (j+3));
- m_List1.SetItemText (i, 4, array.ElementAt (j+4));
- m_List1.SetItemText (i, 5, array.ElementAt (j+5));
- m_List1.SetItemText (i, 6, array.ElementAt (j+6));
- m_List1.SetItemText (i, 7, array.ElementAt (j+7));
- array.RemoveAt (j);
- array.RemoveAt (j);
- array.RemoveAt (j);
- array.RemoveAt (j);
- array.RemoveAt (j);
- array.RemoveAt (j);
- array.RemoveAt (j);
- array.RemoveAt (j);
- break;
- }
- }
-
- }
- }
|