| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176 |
- // SetLoginTime.cpp : implementation file
- //
- #include "stdafx.h"
- #include "ylgl.h"
- #include "SetLoginTime.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // SetLoginTime dialog
- SetLoginTime::SetLoginTime(CWnd* pParent /*=NULL*/)
- : CDialog(SetLoginTime::IDD, pParent)
- {
- //{{AFX_DATA_INIT(SetLoginTime)
- m_name = _T("");
- m_time1 = _T("");
- m_time2 = _T("");
- m_time3 = _T("");
- m_time4 = _T("");
- //}}AFX_DATA_INIT
- }
- void SetLoginTime::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(SetLoginTime)
- DDX_Control(pDX, IDC_LIST1, m_List1);
- DDX_Text(pDX, IDC_EDIT1, m_name);
- DDX_Text(pDX, IDC_EDIT2, m_time1);
- DDX_Text(pDX, IDC_EDIT3, m_time2);
- DDX_Text(pDX, IDC_EDIT4, m_time3);
- DDX_Text(pDX, IDC_EDIT8, m_time4);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(SetLoginTime, CDialog)
- //{{AFX_MSG_MAP(SetLoginTime)
- ON_BN_CLICKED(IDC_BUTadd, OnBUTadd)
- ON_BN_CLICKED(IDC_BUTdel, OnBUTdel)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // SetLoginTime message handlers
- BOOL SetLoginTime::OnInitDialog()
- {
- CDialog::OnInitDialog();
-
- // TODO: Add extra initialization here
-
- m_List1.SetHeadings("班次名称,90;上班时间,90;下班时间,90;上班时间2,95;下班时间2,95" );
- FillGrid();
- this->CenterWindow (g_pMainWnd);
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void SetLoginTime::FillGrid()
- {
- g_sendhead.bsql=0;
- g_sendhead.code[0]=97;
- g_sendhead.tabcount=1;
- g_pMainWnd->ProcessChatMessageRequest2(2);if(g_bSendOK==0)return;
- DataToArray(&g_List1array);
- m_List1.DeleteAllItems2 ();
- int ii=0;
- {
- m_List1.m_arLabels.SetSize( g_List1array.GetSize (), 1 );
- for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
- m_List1.m_arLabels.ElementAt (ii).Copy (g_List1array.ElementAt (ii));
- }
- m_List1.m_LabelCount=ii;
- m_List1.SetItemCountEx (ii);
- }
- void SetLoginTime::OnBUTadd()
- {
- // TODO: Add your control notification handler code here
- UpdateData();
- m_name.TrimLeft ();
- m_name.TrimRight ();
- if(m_name.IsEmpty ())
- {
- AfxMessageBox("班次名称不能为空!", MB_ICONINFORMATION);
- this->GetDlgItem (IDC_EDIT1)->SetFocus();
- return;
- }
- for(int i=0; i<m_List1.GetItemCount (); i++)
- {
- if(m_List1.GetItemText (i, 0)==m_name)
- {
- AfxMessageBox("已有此班次!", MB_ICONINFORMATION);
- this->GetDlgItem (IDC_EDIT1)->SetFocus();
- return;
- }
- }
- m_time1.TrimLeft ();
- m_time1.TrimRight ();
- m_time2.TrimLeft ();
- m_time2.TrimRight ();
- m_time3.TrimLeft ();
- m_time3.TrimRight ();
- m_time4.TrimLeft ();
- m_time4.TrimRight ();
- int pos=m_time1.Find (":");
- if(pos!=2 || m_time1.GetLength ()!=5)
- {
- AfxMessageBox("时间格式不对!", MB_ICONINFORMATION);
- return;
- }
-
- pos=m_time2.Find (":");
- if(pos!=2 || m_time2.GetLength ()!=5)
- {
- AfxMessageBox("时间格式不对!", MB_ICONINFORMATION);
- return;
- }
- if(m_time3!="")
- {
- pos=m_time3.Find (":");
- if(pos!=2 || m_time3.GetLength ()!=5)
- {
- AfxMessageBox("时间格式不对!", MB_ICONINFORMATION);
- return;
- }
- }
- if(m_time4!="")
- {
- pos=m_time4.Find (":");
- if(pos!=2 || m_time4.GetLength ()!=5)
- {
- AfxMessageBox("时间格式不对!", MB_ICONINFORMATION);
- return;
- }
- }
- CString sql;
- sql.Format ("insert into lonintimeset (name,time1,time2,time3,time4)values('%s','%s','%s','%s','%s')", m_name,m_time1,m_time2,m_time3,m_time4);
- g_sendhead.bsql=1;
- g_pMainWnd->ProcessChatMessageRequest2(sql);if(g_bSendOK==0)return;
- FillGrid();
- }
- void SetLoginTime::OnBUTdel()
- {
- // TODO: Add your control notification handler code here
- POSITION pos;
- pos=m_List1.GetFirstSelectedItemPosition();
- if(pos==NULL)
- {
- AfxMessageBox("请选中您要删除的班次!", MB_ICONINFORMATION);
- return;
- }
- if(AfxMessageBox("确认删除吗?", MB_YESNO|MB_ICONINFORMATION)!=IDYES)return;
- int iItem=m_List1.GetNextSelectedItem(pos);
- CString name=m_List1.GetItemText (iItem, 0);
-
- CString sql;
- sql.Format ("delete from lonintimeset where name='%s'", name);
- g_sendhead.bsql=1;
- g_pMainWnd->ProcessChatMessageRequest2(sql);if(g_bSendOK==0)return;
- FillGrid();
- }
|