// 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; iiGetDlgItem (IDC_EDIT1)->SetFocus(); return; } for(int i=0; iGetDlgItem (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(); }