// DLG_Calendar_Add.cpp : implementation file // #include "stdafx.h" #include "corpsms.h" #include "DLG_Calendar_Add.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // DLG_Calendar_Add dialog #include "mainfrm.h" #include "FCAddress.h" DLG_Calendar_Add::DLG_Calendar_Add(CWnd* pParent /*=NULL*/) : CDialog(DLG_Calendar_Add::IDD, pParent) { //{{AFX_DATA_INIT(DLG_Calendar_Add) m_tDate = COleDateTime::GetCurrentTime(); m_bM0 = FALSE; m_bM1 = FALSE; m_bM2 = FALSE; m_bM3 = FALSE; m_bM4 = FALSE; m_bM5 = FALSE; m_bM6 = FALSE; m_strMobile = _T(""); m_strMsg = _T(""); m_lType = -1; m_bEnable = FALSE; m_tTime = COleDateTime::GetCurrentTime(); //}}AFX_DATA_INIT m_pFCAddress = (CFCAddress *)pParent; memset(&m_Data,0,sizeof(m_Data)); m_bAllowSetMobile = false; } void DLG_Calendar_Add::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(DLG_Calendar_Add) DDX_Control(pDX, IDC_CALENDAR_ADD_MOBILE, m_B_Mobile); DDX_Control(pDX, IDC_CALENDAR_ADD_SETMOBILE, m_B_SetMobile); DDX_Control(pDX, IDC_CALENDAR_ADD_SUB, m_B_Sub); DDX_Control(pDX, IDC_CALENDAR_ADD_DAY, m_L_Day); DDX_Control(pDX, IDC_CALENDAR_ADD_MON, m_L_Mon); DDX_DateTimeCtrl(pDX, IDC_CALENDAR_ADD_DATE, m_tDate); DDX_Check(pDX, IDC_CALENDAR_ADD_M0, m_bM0); DDX_Check(pDX, IDC_CALENDAR_ADD_M1, m_bM1); DDX_Check(pDX, IDC_CALENDAR_ADD_M2, m_bM2); DDX_Check(pDX, IDC_CALENDAR_ADD_M3, m_bM3); DDX_Check(pDX, IDC_CALENDAR_ADD_M4, m_bM4); DDX_Check(pDX, IDC_CALENDAR_ADD_M5, m_bM5); DDX_Check(pDX, IDC_CALENDAR_ADD_M6, m_bM6); DDX_Text(pDX, IDC_CALENDAR_ADD_MOBILE, m_strMobile); DDV_MaxChars(pDX, m_strMobile, 12); DDX_Text(pDX, IDC_CALENDAR_ADD_MSG, m_strMsg); DDV_MaxChars(pDX, m_strMsg, 500); DDX_CBIndex(pDX, IDC_CALENDAR_ADD_TYPE, m_lType); DDX_Check(pDX, IDC_CLAENDAR_ADD_STATUS, m_bEnable); DDX_DateTimeCtrl(pDX, IDC_CALENDAR_ADD_TIME, m_tTime); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(DLG_Calendar_Add, CDialog) //{{AFX_MSG_MAP(DLG_Calendar_Add) ON_CBN_SELCHANGE(IDC_CALENDAR_ADD_TYPE, OnSelchangeCalendarAddType) ON_CBN_SELCHANGE(IDC_CALENDAR_ADD_MON, OnSelchangeCalendarAddMon) ON_BN_CLICKED(IDC_CALENDAR_ADD_SUB, OnCalendarAddSub) ON_BN_CLICKED(IDC_CALENDAR_ADD_SETMOBILE, OnCalendarAddSetmobile) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // DLG_Calendar_Add message handlers BOOL DLG_Calendar_Add::OnInitDialog() { CDialog::OnInitDialog(); UpdateData(false); GetDlgItem(IDC_CALENDAR_ADD_DATE)->GetWindowRect(&m_RectD); GetDlgItem(IDC_CALENDAR_ADD_TIME)->GetWindowRect(&m_RectT); m_RectMon.left = m_RectD.left; m_RectMon.right= m_RectD.left+(m_RectD.Width()/2)-2; m_RectMon.top = m_RectD.top; m_RectMon.bottom=m_RectD.bottom; m_RectDay.left = m_RectD.right-(m_RectD.Width()/2)+2; m_RectDay.right= m_RectD.right; m_RectDay.top = m_RectD.top; m_RectDay.bottom=m_RectD.bottom; this->ScreenToClient( &m_RectD ); this->ScreenToClient( &m_RectT ); this->ScreenToClient( &m_RectMon ); this->ScreenToClient( &m_RectDay ); GetDlgItem(IDC_CALENDAR_ADD_MON)->MoveWindow(&m_RectMon); GetDlgItem(IDC_CALENDAR_ADD_DAY)->MoveWindow(&m_RectDay); SYSTEMTIME t;::GetSystemTime(&t); m_L_Mon.SetCurSel(t.wMonth-1); OnSelchangeCalendarAddMon(); OnSelchangeCalendarAddType(); if ( m_bAllowSetMobile ) { m_B_SetMobile.ShowWindow( SW_SHOW ); m_B_Sub.ShowWindow( SW_HIDE ); if ( _tcslen(m_Data.szAddMobile)>=10 ) { m_B_SetMobile.SetCheck(true); m_B_Mobile.SetWindowText(m_Data.szAddMobile); OnCalendarAddSetmobile(); } } else { m_B_SetMobile.ShowWindow( SW_HIDE ); m_B_Sub.ShowWindow( SW_SHOW ); } return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void DLG_Calendar_Add::SetParam(CString strMobile, ANS_Calendar_Data2 data,BOOL bAllowSetMobile) { m_strMobile = strMobile; m_strMobile2 = m_strMobile; m_lType = data.lType; m_bAllowSetMobile = bAllowSetMobile; if ( COleDateTime(data.tAlarm).GetStatus() == COleDateTime::valid ) { m_tDate = data.tAlarm; m_tTime = data.tAlarm; } m_strMsg = data.szMsg; m_bEnable = data.lStatus; CString str = data.szAddMsg; if ( str.Find('0')>=0 ) m_bM0 = true; if ( str.Find('1')>=0 ) m_bM1 = true; if ( str.Find('2')>=0 ) m_bM2 = true; if ( str.Find('3')>=0 ) m_bM3 = true; if ( str.Find('4')>=0 ) m_bM4 = true; if ( str.Find('5')>=0 ) m_bM5 = true; if ( str.Find('6')>=0 ) m_bM6 = true; m_Data = data; } void DLG_Calendar_Add::OnSelchangeCalendarAddType() { UpdateData(true); CString str; int i; switch ( m_lType ) { case 0: //年提醒 SYSTEMTIME t;::GetSystemTime(&t); m_L_Mon.SetCurSel(t.wMonth-1); OnSelchangeCalendarAddMon(); GetDlgItem(IDC_CALENDAR_ADD_TIME)->MoveWindow(&m_RectT); GetDlgItem(IDC_CALENDAR_ADD_MON)->ShowWindow(SW_SHOW); GetDlgItem(IDC_CALENDAR_ADD_DAY)->ShowWindow(SW_SHOW); GetDlgItem(IDC_CALENDAR_ADD_DATE)->ShowWindow(SW_HIDE); GetDlgItem(IDC_CALENDAR_ADD_MS)->ShowWindow(SW_HIDE); GetDlgItem(IDC_CALENDAR_ADD_M0)->ShowWindow(SW_HIDE); GetDlgItem(IDC_CALENDAR_ADD_M1)->ShowWindow(SW_HIDE); GetDlgItem(IDC_CALENDAR_ADD_M2)->ShowWindow(SW_HIDE); GetDlgItem(IDC_CALENDAR_ADD_M3)->ShowWindow(SW_HIDE); GetDlgItem(IDC_CALENDAR_ADD_M4)->ShowWindow(SW_HIDE); GetDlgItem(IDC_CALENDAR_ADD_M5)->ShowWindow(SW_HIDE); GetDlgItem(IDC_CALENDAR_ADD_M6)->ShowWindow(SW_HIDE); break; case 1: //月提醒 //默认可以选31日 m_L_Day.ResetContent(); for ( i=0 ; i<31 ; i++ ) { str.Format(_T("%d"),i+1); m_L_Day.AddString(str); } m_L_Day.SetCurSel(0); GetDlgItem(IDC_CALENDAR_ADD_TIME)->MoveWindow(&m_RectT); GetDlgItem(IDC_CALENDAR_ADD_DAY)->ShowWindow(SW_SHOW); GetDlgItem(IDC_CALENDAR_ADD_MON)->ShowWindow(SW_HIDE); GetDlgItem(IDC_CALENDAR_ADD_DATE)->ShowWindow(SW_HIDE); GetDlgItem(IDC_CALENDAR_ADD_MS)->ShowWindow(SW_HIDE); GetDlgItem(IDC_CALENDAR_ADD_M0)->ShowWindow(SW_HIDE); GetDlgItem(IDC_CALENDAR_ADD_M1)->ShowWindow(SW_HIDE); GetDlgItem(IDC_CALENDAR_ADD_M2)->ShowWindow(SW_HIDE); GetDlgItem(IDC_CALENDAR_ADD_M3)->ShowWindow(SW_HIDE); GetDlgItem(IDC_CALENDAR_ADD_M4)->ShowWindow(SW_HIDE); GetDlgItem(IDC_CALENDAR_ADD_M5)->ShowWindow(SW_HIDE); GetDlgItem(IDC_CALENDAR_ADD_M6)->ShowWindow(SW_HIDE); break; case 4: //提醒一次 GetDlgItem(IDC_CALENDAR_ADD_DATE)->MoveWindow(&m_RectD); GetDlgItem(IDC_CALENDAR_ADD_TIME)->MoveWindow(&m_RectT); GetDlgItem(IDC_CALENDAR_ADD_DATE)->ShowWindow(SW_SHOW); GetDlgItem(IDC_CALENDAR_ADD_TIME)->ShowWindow(SW_SHOW); GetDlgItem(IDC_CALENDAR_ADD_MS)->ShowWindow(SW_HIDE); GetDlgItem(IDC_CALENDAR_ADD_M0)->ShowWindow(SW_HIDE); GetDlgItem(IDC_CALENDAR_ADD_M1)->ShowWindow(SW_HIDE); GetDlgItem(IDC_CALENDAR_ADD_M2)->ShowWindow(SW_HIDE); GetDlgItem(IDC_CALENDAR_ADD_M3)->ShowWindow(SW_HIDE); GetDlgItem(IDC_CALENDAR_ADD_M4)->ShowWindow(SW_HIDE); GetDlgItem(IDC_CALENDAR_ADD_M5)->ShowWindow(SW_HIDE); GetDlgItem(IDC_CALENDAR_ADD_M6)->ShowWindow(SW_HIDE); GetDlgItem(IDC_CALENDAR_ADD_MON)->ShowWindow(SW_HIDE); GetDlgItem(IDC_CALENDAR_ADD_DAY)->ShowWindow(SW_HIDE); break; case 2: //周提醒 GetDlgItem(IDC_CALENDAR_ADD_TIME)->MoveWindow(&m_RectD); GetDlgItem(IDC_CALENDAR_ADD_TIME)->ShowWindow(SW_SHOW); GetDlgItem(IDC_CALENDAR_ADD_DATE)->ShowWindow(SW_HIDE); GetDlgItem(IDC_CALENDAR_ADD_MS)->ShowWindow(SW_SHOW); GetDlgItem(IDC_CALENDAR_ADD_M0)->ShowWindow(SW_SHOW); GetDlgItem(IDC_CALENDAR_ADD_M1)->ShowWindow(SW_SHOW); GetDlgItem(IDC_CALENDAR_ADD_M2)->ShowWindow(SW_SHOW); GetDlgItem(IDC_CALENDAR_ADD_M3)->ShowWindow(SW_SHOW); GetDlgItem(IDC_CALENDAR_ADD_M4)->ShowWindow(SW_SHOW); GetDlgItem(IDC_CALENDAR_ADD_M5)->ShowWindow(SW_SHOW); GetDlgItem(IDC_CALENDAR_ADD_M6)->ShowWindow(SW_SHOW); GetDlgItem(IDC_CALENDAR_ADD_MON)->ShowWindow(SW_HIDE); GetDlgItem(IDC_CALENDAR_ADD_DAY)->ShowWindow(SW_HIDE); break; case 3: //日提醒 GetDlgItem(IDC_CALENDAR_ADD_TIME)->MoveWindow(&m_RectD); GetDlgItem(IDC_CALENDAR_ADD_TIME)->ShowWindow(SW_SHOW); GetDlgItem(IDC_CALENDAR_ADD_DATE)->ShowWindow(SW_HIDE); GetDlgItem(IDC_CALENDAR_ADD_MS)->ShowWindow(SW_HIDE); GetDlgItem(IDC_CALENDAR_ADD_M0)->ShowWindow(SW_HIDE); GetDlgItem(IDC_CALENDAR_ADD_M1)->ShowWindow(SW_HIDE); GetDlgItem(IDC_CALENDAR_ADD_M2)->ShowWindow(SW_HIDE); GetDlgItem(IDC_CALENDAR_ADD_M3)->ShowWindow(SW_HIDE); GetDlgItem(IDC_CALENDAR_ADD_M4)->ShowWindow(SW_HIDE); GetDlgItem(IDC_CALENDAR_ADD_M5)->ShowWindow(SW_HIDE); GetDlgItem(IDC_CALENDAR_ADD_M6)->ShowWindow(SW_HIDE); GetDlgItem(IDC_CALENDAR_ADD_MON)->ShowWindow(SW_HIDE); GetDlgItem(IDC_CALENDAR_ADD_DAY)->ShowWindow(SW_HIDE); break; } } void DLG_Calendar_Add::OnOK() { if ( !UpdateData(true) ) return ; if ( m_strMobile.GetLength() < 10 ) { #ifdef MOBSET_CARD_VER MessageBox( _T("手机号码有误,请联系在用户信息中更改!"),_T("错误"),MB_ICONWARNING ); #else MessageBox( _T("手机号码有误,请联系管理员修改你的资料!"),_T("错误"),MB_ICONWARNING ); #endif return ; } if ( m_strMsg.GetLength() <= 0 ) { MessageBox( _T("提示信息不能为空,请输入!") , _T("错误") , MB_ICONWARNING ); GetDlgItem(IDC_CALENDAR_ADD_MSG)->SetFocus(); return; } if ( m_B_SetMobile.GetCheck() ) { _tcscpy(m_Data.szAddMobile , m_strMobile ); } else { memset(m_Data.szAddMobile,0,sizeof(m_Data.szAddMobile)); } m_Data.lType = m_lType; _tcscpy(m_Data.szMsg,m_strMsg); m_Data.lStatus = m_bEnable; SYSTEMTIME t; m_tDate.GetAsSystemTime(t); m_tTime.GetAsSystemTime(m_Data.tAlarm); m_Data.tAlarm.wYear = t.wYear; m_Data.tAlarm.wMonth= t.wMonth; m_Data.tAlarm.wDay = t.wDay; if ( m_lType==0||m_lType==1 ) { m_Data.tAlarm.wMonth= m_L_Mon.GetCurSel()+1; m_Data.tAlarm.wDay = m_L_Day.GetCurSel()+1; } CString str=_T(""); if ( m_bM0 ) str += _T("0"); if ( m_bM1 ) str += _T("1"); if ( m_bM2 ) str += _T("2"); if ( m_bM3 ) str += _T("3"); if ( m_bM4 ) str += _T("4"); if ( m_bM5 ) str += _T("5"); if ( m_bM6 ) str += _T("6"); _tcscpy( m_Data.szAddMsg , str ); if ( m_bEnable && m_lType==2 && str.GetLength()<=0 ) //周提醒 { MessageBox( _T("你已设置了周提醒,但你没设置提醒的星期,请检查!"),_T("错误"),MB_ICONWARNING ); GetDlgItem(IDC_CALENDAR_ADD_M0)->SetFocus(); return; } if ( m_bEnable && m_lType==4 ) //提醒一次,检查时间是否正常 { COleDateTime tNow = COleDateTime::GetCurrentTime(); if ( COleDateTime(m_Data.tAlarm) <= tNow ) { MessageBox( _T("所设置的提醒时间小于当前时间,请检查!"),_T("错误"),MB_ICONWARNING ); GetDlgItem(IDC_CALENDAR_ADD_DATE)->SetFocus(); return; } } CDialog::OnOK(); } void DLG_Calendar_Add::OnSelchangeCalendarAddMon() { long l = m_L_Mon.GetCurSel()+1; long lMax=0; switch (l) { case 1: case 3: case 5: case 7: case 8: case 10: case 12: lMax=31; break; case 2: lMax=29; break; default: lMax=30; } CString str; m_L_Day.ResetContent(); for ( int i=0 ; im_pFCAddress->m_pMainFrame->OnTYj2(_T("申请改日程号码")); } void DLG_Calendar_Add::OnCalendarAddSetmobile() { if ( m_B_SetMobile.GetCheck() ) { m_B_Mobile.SetReadOnly(false); } else { m_B_Mobile.SetReadOnly(true); m_B_Mobile.SetWindowText(m_strMobile2); } }