⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 newsserch.cpp

📁 一个电视台专用的信息管理软件源代码
💻 CPP
字号:
// NewsSerch.cpp : implementation file
//

#include "stdafx.h"
#include "tvnews.h"
#include "NewsSerch.h"
#include "Channel.h"
#include "Column.h"
#include "Users.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CNewsSerch dialog


CNewsSerch::CNewsSerch(CWnd* pParent /*=NULL*/)
	: CDialog(CNewsSerch::IDD, pParent)
{
	//{{AFX_DATA_INIT(CNewsSerch)
	m_Channel = _T("");
	m_Column = _T("");
	m_State = _T("");
	m_Title = _T("");
	m_Time1 = COleDateTime::GetCurrentTime();
	m_Time2 = COleDateTime::GetCurrentTime();
	//}}AFX_DATA_INIT
}


void CNewsSerch::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CNewsSerch)
	DDX_Control(pDX, IDC_COMBO_STATE, m_cmbState);
	DDX_Control(pDX, IDC_COMBO_CHANNEL, m_cmbChannel);
	DDX_Control(pDX, IDC_COMBO_COLUM, m_cmbColumn);
	DDX_CBString(pDX, IDC_COMBO_CHANNEL, m_Channel);
	DDX_CBString(pDX, IDC_COMBO_COLUM, m_Column);
	DDX_CBString(pDX, IDC_COMBO_STATE, m_State);
	DDX_Text(pDX, IDC_EDIT_TITLE, m_Title);
	DDX_DateTimeCtrl(pDX, IDC_DATETIMEPICKER1, m_Time1);
	DDX_DateTimeCtrl(pDX, IDC_DATETIMEPICKER2, m_Time2);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CNewsSerch, CDialog)
	//{{AFX_MSG_MAP(CNewsSerch)
	ON_CBN_SELCHANGE(IDC_COMBO_CHANNEL, OnSelchangeComboChannel)
	ON_CBN_SELCHANGE(IDC_COMBO_COLUM, OnSelchangeComboColum)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CNewsSerch message handlers

void CNewsSerch::OnOK() 
{
	// TODO: Add extra validation here
	UpdateData(true);


	strSQL="";
	CString strID;
	if(ChannelID==0)
	{
		strSQL=strSQL+" ";
	}
	else
	{
		strID.Format("%d",ChannelID);
		strSQL=strSQL+" and ChannelID= "+strID;
	}
	if(ColumnID==0)
	{
		strSQL=strSQL+" ";
	}
	else
	{
		strID.Format("%d",ColumnID);
		strSQL=strSQL+ " and ( ColumnID= "+strID + " ) ";
	}
	
	m_Title.TrimRight();
	m_Title.TrimLeft();

	if(m_Title=="")
	{	
		strSQL=strSQL+" ";
	}
	else
	{
		strSQL=strSQL+ " and Title like '%" +m_Title + "%'";
	}

	if((m_State=="所有状态")||(m_State==""))
	{	
		strSQL=strSQL+" ";
	}
	else if(m_State=="审核通过")
	{
	
		strSQL=strSQL + " and News.State = 0 ";
	}
	else if(m_State=="待审核")
	{
	
		strSQL=strSQL + " and News.State = 1 ";
	}
	else if(m_State=="审核未通过")
	{
	
		strSQL=strSQL + " and News.State = 2 ";
	}
	else if(m_State=="审核中")
	{
	
		strSQL=strSQL + " and News.State = 3 ";
	}
	CString strDate1,strDate2;

	strDate1 = m_Time1.Format (_T("%Y-%m-%d"));
	strDate2.Format("%4d-%2d-%2d",m_Time2.GetYear(),m_Time2.GetMonth(),m_Time2.GetDay()+1);
	

	strSQL= strSQL + " AND (SendTime BETWEEN '" + strDate1 +"' AND '" + strDate2 + "')"; 

	
	CDialog::OnOK();
}

void CNewsSerch::OnSelchangeComboChannel() 
{
	// TODO: Add your control notification handler code here
	CChannel Channel;
	UpdateData(true);
	int number = m_cmbChannel.GetCurSel(); 
	CString strName;
	m_cmbChannel.GetLBText(number,strName);
	ChannelID = Channel.GetIDByName(strName);
	
	GetColumnChannelList(1);
	
}

void CNewsSerch::OnSelchangeComboColum() 
{
	// TODO: Add your control notification handler code here
	CColumn Column;
	UpdateData(true);
	int number = m_cmbColumn.GetCurSel(); 
	CString strName;
	m_cmbColumn.GetLBText(number,strName);
	ColumnID = Column.GetIDByName(strName);
	GetColumnChannelList(0);

}
void CNewsSerch::GetColumnChannelList(int Type)
{
		if(Type==1)//频道引起栏目变化
	{
		CChannel Channel;
		UpdateData(true);
	
		CString strSQL,strID;
		CColumn Column;

		if(ChannelID==0)
			strSQL="";
		else
		{
			strID.Format("%d", ChannelID);
			strSQL= " AND ChannelID = " + strID ;
		}
		CStringArray allColumns;
		Column.GetAllColumn(allColumns,strSQL);
		int i;
		m_cmbColumn.ResetContent();
		if(ChannelID!=0)	
		{
			m_cmbColumn.AddString("所有栏目");
		}
		for(i=0;i<allColumns.GetSize();i++)
		{
			m_cmbColumn.AddString(_T(allColumns.GetAt(i)));	
		}
			
		m_cmbColumn.SelectString(-1,"所有栏目");
		ColumnID = 0;
	}
	
	else
	{
		
		CColumn Column;
		UpdateData(true);
		int number = m_cmbColumn.GetCurSel(); 
		CString strName;
		m_cmbColumn.GetLBText(number,strName);
		ColumnID = Column.GetIDByName(strName);
		Column.GetData(ColumnID);
		
		ChannelID=Column.GetChannelID();

		CString strSQL,strID;
		
		CChannel Channel;
		Channel.GetData(ChannelID);
		
		m_cmbChannel.SelectString(-1,Channel.GetName());

		
	}
	

}

BOOL CNewsSerch::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	CChannel Channel;
	CStringArray allChannels;
	Channel.GetAllChannel(allChannels);
	m_cmbChannel.ResetContent();
	int i;
	for(i=0;i<allChannels.GetSize();i++)
	{
		m_cmbChannel.AddString(_T(allChannels.GetAt(i)));	
	}
	
	m_cmbChannel.SelectString(-1,"所有频道");
	ChannelID=0;
	GetColumnChannelList(1);
	m_cmbState.SelectString(-1,"所有状态");
	
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CNewsSerch::OnCancel() 
{
	// TODO: Add extra cleanup here
	
	CDialog::OnCancel();
}

BOOL CNewsSerch::PreTranslateMessage(MSG* pMsg) 
{
	// TODO: Add your specialized code here and/or call the base class
	if(pMsg->message   ==   WM_KEYDOWN)   
     {   
           if(pMsg->wParam   ==   VK_RETURN)   
           {   
			    CWnd   *pWnd   =   GetFocus();   
                if(pWnd->GetDlgCtrlID()==IDOK)
				{
					OnOK();
				}
				else if(pWnd->GetDlgCtrlID()==IDCANCEL)
				{
					OnCancel();
				}
				else
				{
					NextDlgCtrl();
					return true;
				}
            }   
       }    

	
	return CDialog::PreTranslateMessage(pMsg);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -