📄 communicate.cpp
字号:
// communicate.cpp : implementation file
//
#include "stdafx.h"
#include "LMTS.h"
#include "communicate.h"
#include "comment.h"
#include "user.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// communicate dialog
communicate::communicate(CWnd* pParent /*=NULL*/)
: CDialog(communicate::IDD, pParent)
{
//{{AFX_DATA_INIT(communicate)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
BOOL communicate::OnInitDialog()
{
CDialog::OnInitDialog();
comment show_com;
CString str,user_id;
GetDlgItem(IDC_EDIT4)->GetWindowText(user_id);
str.Format("select * from comment where receive='%s'",user_id);
show_com.Open(AFX_DB_USE_DEFAULT_TYPE,str);
if(show_com.GetRecordCount()!=0){
show_com.MoveFirst();
while(!show_com.IsEOF())
{
CString temp,temp_msg;
temp=show_com.m_content;
GetDlgItem(IDC_EDIT3)->GetWindowText(temp_msg);
GetDlgItem(IDC_EDIT3)->SetWindowText(temp+"\n\t"+temp_msg);
show_com.MoveNext();
}
}
show_com.Close();
return TRUE;
}
void communicate::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(communicate)
DDX_Text(pDX, IDC_EDIT1, receiver);
DDX_Text(pDX, IDC_EDIT2, send_message);
DDX_Text(pDX, IDC_EDIT3, receive_message);
DDX_Text(pDX, IDC_EDIT4, sender);// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
void communicate::OnButton1()
{
AfxEnableControlContainer();
comment com_form(&cf);
user search_user;
CString sender,send_msg,receive_msg,receiver;
GetDlgItem(IDC_EDIT1)->GetWindowText(receiver);
GetDlgItem(IDC_EDIT2)->GetWindowText(send_msg);
GetDlgItem(IDC_EDIT3)->GetWindowText(receive_msg);
GetDlgItem(IDC_EDIT4)->GetWindowText(sender);
CString str,str1,strSQL;
str.Format("select * from user where id='%s'",receiver);
search_user.Open(AFX_DB_USE_DEFAULT_TYPE,str);
//if(com_form.GetRecordCount()!=0){
if(search_user.GetRecordCount()!=0)
{
str1.Format("select * from comment");
com_form.Open(AFX_DB_USE_DEFAULT_TYPE,str1);
if(com_form.GetRecordCount()!=0){
com_form.MoveLast();
int i=0;
i=com_form.m_column1+1;
strSQL.Format("insert into comment values(%d,'%s','%s','%s')",i,sender,send_msg,receiver);
cf.ExecuteSQL(strSQL);
cf.Close();
}
else
{
strSQL.Format("insert into comment values(%d,'%s','%s','%s')",0,sender,send_msg,receiver);
cf.ExecuteSQL(strSQL);
cf.Close();
}
}
else
{
AfxMessageBox("不存在该用户");
}
CDialog::OnOK();
// }
// }
}
BEGIN_MESSAGE_MAP(communicate, CDialog)
//{{AFX_MSG_MAP(communicate)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1) // NOTE: the ClassWizard will add message map macros here
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// communicate message handlers
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -