123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- // SelMsgContent2.cpp : implementation file
- //
- #include "stdafx.h"
- #include "ylgl.h"
- #include "SelMsgContent2.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // SelMsgContent2 dialog
- SelMsgContent2::SelMsgContent2(CWnd* pParent /*=NULL*/)
- : CDialog(SelMsgContent2::IDD, pParent)
- {
- //{{AFX_DATA_INIT(SelMsgContent2)
- m_content = _T("");
- m_title = _T("");
- //}}AFX_DATA_INIT
- }
- void SelMsgContent2::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(SelMsgContent2)
- DDX_Control(pDX, IDC_LIST1, m_List1);
- DDX_Text(pDX, IDC_EDIT1, m_content);
- DDV_MaxChars(pDX, m_content, 1000);
- DDX_Text(pDX, IDC_EDIT2, m_title);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(SelMsgContent2, CDialog)
- //{{AFX_MSG_MAP(SelMsgContent2)
- ON_LBN_SELCHANGE(IDC_LIST1, OnSelchangeList1)
- ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // SelMsgContent2 message handlers
- BOOL SelMsgContent2::OnInitDialog()
- {
- CDialog::OnInitDialog();
-
- // TODO: Add extra initialization here
- g_sendhead.bsql=0;
- g_sendhead.code[0]=134;
- g_sendhead.tabcount=1;
- g_pMainWnd->ProcessChatMessageRequest2(1);if(g_bSendOK==0)return false;
- DataToArray(&m_List1array);
- for(int i=0; i<m_List1array.GetSize (); i++)
- {
- m_List1.AddString (m_List1array.ElementAt (i).ElementAt (0));
- }
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void SelMsgContent2::OnOK()
- {
- // TODO: Add extra validation here
- UpdateData();
- if(m_title.IsEmpty ())return;
- for(int i=0; i<m_List1array.GetSize (); i++)
- {
- if(m_title==m_List1array.ElementAt (i).ElementAt (0))
- {MessageBox("已有此模板的记录");
- return;
- }
- }
- CString sql="insert into msgtemp(title,content)values('"+m_title+"','"+m_content+"')";
- g_sendhead.bsql=1;
- g_pMainWnd->ProcessChatMessageRequest2(sql);if(g_bSendOK==0)return;
- MessageBox("保存成功");
- m_List1.AddString (m_title);
- int size=m_List1array.GetSize ();
- m_List1array.SetSize(size+1, 1);
- m_List1array.ElementAt (size).RemoveAll ();
- m_List1array.ElementAt (size).Add (m_title);
- m_List1array.ElementAt (size).Add (m_content);
- }
- void SelMsgContent2::OnSelchangeList1()
- {
- // TODO: Add your control notification handler code here
- int pos=m_List1.GetCurSel ();
- if(pos==-1)return;
- m_title=m_List1array.ElementAt (pos).ElementAt (0);
- m_content=m_List1array.ElementAt (pos).ElementAt (1);
- UpdateData(false);
- }
- void SelMsgContent2::OnButton1()
- {
- // TODO: Add your control notification handler code here
- int pos=m_List1.GetCurSel ();
- if(pos==-1)return;
- if(AfxMessageBox("删除后将无法恢复,是否继续?", MB_YESNO|MB_ICONINFORMATION)!=IDYES)return;
- m_title=m_List1array.ElementAt (pos).ElementAt (0);
- m_content=m_List1array.ElementAt (pos).ElementAt (1);
- CString sql="delete from msgtemp where title='"+m_title+"'";
- g_sendhead.bsql=1;
- g_pMainWnd->ProcessChatMessageRequest2(sql);if(g_bSendOK==0)return;
-
- m_List1.DeleteString (pos);
-
- m_List1array.RemoveAt(pos);
-
-
- }
|