// SetChildMsg.cpp : implementation file // #include "stdafx.h" #include "ylgl.h" #include "SetChildMsg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // SetChildMsg dialog SetChildMsg::SetChildMsg(CWnd* pParent /*=NULL*/) : CDialog(SetChildMsg::IDD, pParent) { //{{AFX_DATA_INIT(SetChildMsg) m_check1 = FALSE; m_days = _T(""); m_content = _T(""); m_mode=0; //}}AFX_DATA_INIT } void SetChildMsg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(SetChildMsg) DDX_Control(pDX, IDC_COMBO1, m_combo1); DDX_Control(pDX, IDC_LIST1, m_List1); DDX_Check(pDX, IDC_CHECK1, m_check1); DDX_CBString(pDX, IDC_COMBO1, m_days); DDX_Text(pDX, IDC_EDIT1, m_content); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(SetChildMsg, CDialog) //{{AFX_MSG_MAP(SetChildMsg) ON_LBN_SELCHANGE(IDC_LIST1, OnSelchangeList1) ON_BN_CLICKED(IDC_BUTadd, OnBUTadd) ON_BN_CLICKED(IDC_BUTdel, OnBUTdel) ON_EN_CHANGE(IDC_EDIT1, OnChangeEdit1) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // SetChildMsg message handlers BOOL SetChildMsg::OnInitDialog() { CDialog::OnInitDialog(); // TODO: Add extra initialization here if(m_mode==1 || m_mode==0) { SetWindowText("宝宝成长跟踪短信"); m_combo1.AddString ("一周"); m_combo1.AddString ("两周"); m_combo1.AddString ("三周"); m_combo1.AddString ("满月"); m_combo1.AddString ("两个月"); m_combo1.AddString ("三个月"); m_combo1.AddString ("六个月"); m_combo1.AddString ("一岁"); m_combo1.AddString ("两岁"); m_combo1.AddString ("三岁"); } else if(m_mode==2) { SetWindowText("怀孕周期提醒短信"); GetDlgItem(IDC_STATIC2)->SetWindowText("怀孕满(x天):"); m_combo1.AddString ("一周"); m_combo1.AddString ("两周"); m_combo1.AddString ("三周"); m_combo1.AddString ("一个月"); m_combo1.AddString ("两个月"); m_combo1.AddString ("三个月"); m_combo1.AddString ("六个月"); m_combo1.AddString ("七个月"); m_combo1.AddString ("八个月"); m_combo1.AddString ("九个月"); } GetData(); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void SetChildMsg::OnSelchangeList1() { // TODO: Add your control notification handler code here int pos=m_List1.GetCurSel (); if(pos==-1) { m_olddays=""; return; } m_days=daysarray.ElementAt (pos); m_olddays=m_days; m_content=contentarray.ElementAt (pos); m_check1=checkarray.ElementAt (pos) ; UpdateData(false); } void SetChildMsg::OnBUTadd() { // TODO: Add your control notification handler code here UpdateData(); m_days.TrimLeft (); m_days.TrimRight (); if(m_days.IsEmpty ()) { AfxMessageBox("天数不能为空!", MB_ICONINFORMATION); return; } if(m_content.IsEmpty ()) { AfxMessageBox("内容不能为空!", MB_ICONINFORMATION); return; } CString sql; if(m_days!=m_olddays) { if(::FindArray (&daysarray, m_days)!=-1) { AfxMessageBox("已有此天数的记录!", MB_ICONINFORMATION); return; } sql.Format ("insert into [childmsg]([check],[days],[content],[mode])values('%d','%s','%s','%d')", m_check1,m_days,m_content,m_mode); } else { sql.Format ("update [childmsg] set [check]='%d',[content]='%s' where [days]='%s' and [mode]='%d'", m_check1,m_content,m_days,m_mode); } g_sendhead.bsql=1; g_pMainWnd->ProcessChatMessageRequest2(sql);if(g_bSendOK==0)return; GetData(); } void SetChildMsg::OnBUTdel() { // TODO: Add your control notification handler code here int pos=m_List1.GetCurSel (); if(pos==-1) { AfxMessageBox("请选中您要删除的项目!" , MB_ICONINFORMATION); return; } if(AfxMessageBox("确认删除吗?", MB_ICONINFORMATION|MB_YESNO)!=IDYES)return; CString sql; CString days=daysarray.ElementAt (pos); sql.Format ("delete from [childmsg] where [days]='%s' and [mode]='%d'", days, m_mode); g_sendhead.bsql=1; g_pMainWnd->ProcessChatMessageRequest2(sql);if(g_bSendOK==0)return; m_List1.DeleteString (pos); daysarray.RemoveAt(pos); contentarray.RemoveAt(pos); checkarray.RemoveAt(pos); } void SetChildMsg::OnChangeEdit1() { // TODO: If this is a RICHEDIT control, the control will not // send this notification unless you override the CDialog::OnInitDialog() // function and call CRichEditCtrl().SetEventMask() // with the ENM_CHANGE flag ORed into the mask. UpdateData(); m_content.Replace ("'", "'"); m_content.Replace ("(", "("); m_content.Replace (")", ")"); UpdateData(false); CString str; int count=0; int leng=GetLengthEx(m_content)+7; count+=(leng/MSG_LENGTH); if(leng%MSG_LENGTH) count+=1; str.Format ("内容:%d字/条,现%d字,共%d条)", MSG_LENGTH,leng,count); GetDlgItem(IDC_STATIC1)->SetWindowText(str); // TODO: Add your control notification handler code here } BOOL SetChildMsg::HasDay(CString days) { CString str; for(int i=0; iProcessChatMessageRequest2(filter); if(g_bSendOK==0) { CDialog::OnCancel (); return; } DataToArray(&g_List1array); CenterWindow(); checkarray.RemoveAll (); daysarray.RemoveAll (); contentarray.RemoveAll (); m_List1.ResetContent (); for(int i=0; i