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

📄 news.cpp

📁 一个电视台专用的信息管理软件源代码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// News.cpp: implementation of the CNews class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "News.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CNews::CNews()
{

}

CNews::~CNews()
{

}
CString CNews::GetIPStr()
{
	return IPStr;
}
CString CNews::GetFilePath()
{
	return FilePath;
}
void CNews::SetIPStr(CString cIPStr)
{
	IPStr=cIPStr;
}
void CNews::SetFilePath(CString cFilePath)
{
	FilePath=cFilePath;
}

int CNews::GetUID()
{
	return UID;
}

CString CNews::GetTitle()
{
	return Title;
}

int CNews::GetUserID()
{
	return UserID;
}

int	CNews::GetChannelID()
{
	return ChannelID;
}

int CNews::GetColumnID()
{
	return ColumnID;
}
CString CNews::GetDesc()
{
	return Desc;
}

CString CNews::GetFileName()
{
	return FileName;
}

int CNews::GetFileSize()
{
	return FileSize;
}

CString CNews::GetSendTime()
{
	return SendTime;
}

CString CNews::GetPassTime()
{
	return PassTime;
}
int CNews::GetState()
{
	return State;
}
int CNews::GetIsDelete()
{
	return IsDelete;
}




void CNews::SetUID(int iUID)
{
	UID=iUID;
}

void CNews::SetTitle(CString cTitle)
{
	Title=cTitle;
}
	
void CNews::SetUserID(int iUserID)
{
	UserID=iUserID;
}

void CNews::SetChannelID(int iChannelID)
{
	ChannelID=iChannelID;
}
	
void CNews::SetColumnID(int iColumnID)
{
	ColumnID=iColumnID;
}

	
void CNews::SetDesc(CString cDesc)
{
	Desc=cDesc;
}
	
void CNews::SetFileName(CString cFileName)
{
	FileName=cFileName;
}
	
void CNews::SetFileSize(int iFileSize)
{
	FileSize=iFileSize;
}

void CNews::SetSendTime(CString cSendTime)
{
	SendTime=cSendTime;
}

void CNews::SetPassTime(CString cPassTime)
{
	PassTime=cPassTime;
}
	
void CNews::SetState(int iState)
{
	State=iState;
}

void CNews::SetIsDelete(int iIsDelete)
{
	IsDelete=iIsDelete;
}

void CNews::SetMustAuditID(int iMustAuditID)
{
	MustAuditID=iMustAuditID;
}

int CNews::GetMustAuditID()
{
	return MustAuditID;
}
//PASS
void CNews::sql_insert(CString cTitle,int iUserID,int iChannelID,int iColumnID,CString cDesc,CString cFileName,int iFileSize,CString cSendTime,CString cPassTime,CString cState,CString cIsDelete,CString cIsAudit)
{
	//设置INSERT语句
	CString strUserID,strChannelID,strColumnID,strSize;
	strUserID.Format("%d", iUserID);
	strChannelID.Format("%d", iChannelID);
	strColumnID.Format("%d", iColumnID);
	strSize.Format("%d", iFileSize);


	vSQL = "INSERT INTO News VALUES('" + cTitle + "'," +strUserID + "," + strChannelID + ","  + strColumnID + ", '" + cDesc + "','" + cFileName + "',"+ strSize + ",'" + cSendTime+ "','" + cPassTime + "','" + cState + "','" + cIsDelete + "','" + cIsAudit + "')";
	//执行INSERT语句
	ExecuteSQL(vSQL);	

}
void CNews::sql_update(int iUID,CString cTitle,int iUserID,int iChannelID,int iColumnID,CString cDesc,CString cFileName,int iFileSize,CString cSendTime,CString cPassTime,CString cState,CString cIsDelete,CString cIsAudit)
{
	//设置UPDATE语句
	CString strUID,strUserID,strChannelID,strColumnID,strSize;
	strUID.Format("%d", iUID);
	strUserID.Format("%d", iUserID);
	strChannelID.Format("%d", iChannelID);
	strColumnID.Format("%d", iColumnID);
	strSize.Format("%d", iFileSize);

	vSQL = " UPDATE News SET Title='" + cTitle + "', UserID=" +strUserID + ", ChannelID = " + strChannelID + ", ColumnID = "  + strColumnID + ", Description ='" + cDesc + "', FileName = '" + cFileName + "', FileSize ="+ strSize + ", SendTime ='" + cSendTime+ "', PassTime= '" + cPassTime + "',IsDelete= '" + cIsDelete + "', State ='" + cState + "', IsAudit ='" + cIsAudit + "' Where UID= "+strUID;
	//执行INSERT语句
	ExecuteSQL(vSQL);	
}
void CNews::ReadNews(int iUID)
{
	CString strUID;
	strUID.Format("%d", iUID);

	vSQL = "UPDATE News SET IsNew=0 WHERE IsDelete = 0 AND UID = "+ strUID;

	//执行INSERT语句
	ExecuteSQL(vSQL);	
}

void CNews::sql_delete(int iUID)
{
	//设置DELETE语句
	CString strUID;
	strUID.Format("%d", iUID);

	vSQL = "UPDATE News SET IsDelete= 1 WHEW UID = "+ strUID;

	//执行INSERT语句
	ExecuteSQL(vSQL);	

}

void CNews::GetData(int UID)
{
	
	//设置SELECT语句
	CString strUID;
	strUID.Format("%d",UID);
	
	vSQL = "SELECT * FROM News WHERE IsDelete = 0 AND UID=" + strUID;
	//执行SELETE语句
	m_pRecordset = GetRecordSet(vSQL);


	
	//返回各列的值
	if (m_pRecordset->adoEOF)
		CNews();
	else
	{
		
		Title = (LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("Title");
		
		UserID = atoi((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("UserID"));
		
		ChannelID = atoi((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("ChannelID"));
		ColumnID = atoi((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("ColumnID"));


		_variant_t varDesc = m_pRecordset->GetCollect("Description");
		if(varDesc.vt != VT_NULL)
		{
			Desc = (LPCSTR)(_bstr_t)varDesc;
		}


		FileName = (LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("FileName");
		FileSize = atoi((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("FileSize"));
		
		SendTime = (LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("SendTime");
		
		_variant_t varPassTime = m_pRecordset->GetCollect("PassTime");
		if(varPassTime.vt != VT_NULL)
		{
			PassTime = (LPCSTR)(_bstr_t)varPassTime;
		}

		State = atoi((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("State"));

		IsDelete = atoi((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("IsDelete"));

		MustAuditID = atoi((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("MustAuditID"));

		IPStr = (LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("IPStr");
		FilePath = (LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("FilePath");

		
	}
	
}

void CNews::ShowList(CListCtrl& listctrl)
{
	int i=0;
    LV_ITEM lvitem;
	lvitem.mask=LVIF_TEXT | LVIF_IMAGE | LVIF_STATE;
	lvitem.state=0;
	lvitem.stateMask=0;

	CString strTitle;
	CString strFileName;
	CString strFileSize;
	CString strSendTime;
	CString strPassTime;
	CString strState;

	//设置SELECT语句
	vSQL = "SELECT * FROM News WHERE IsDelete = 0";
	
	//执行SELETE语句
	m_pRecordset = GetRecordSet(vSQL);
    
	
	 while(!m_pRecordset->adoEOF)
	{   
		lvitem.iItem=i;
		lvitem.iSubItem=0;

		_variant_t varTitle = m_pRecordset->GetCollect("Title");
		if(varTitle.vt != VT_NULL)
		{
			strTitle = (LPCSTR)(_bstr_t)(varTitle);
		}
		lvitem.pszText=(LPTSTR)(LPCTSTR)strTitle; 
		listctrl.InsertItem(&lvitem);

		_variant_t varFileName= m_pRecordset->GetCollect("FileName");
		if(varFileName.vt != VT_NULL)
		{
			strFileName = (LPCSTR)(_bstr_t)(varFileName);
		}
		listctrl.SetItemText(i,1,strFileName);

		_variant_t varFileSize = m_pRecordset->GetCollect("FileSize");
		if(varFileSize.vt != VT_NULL)
		{
			strFileSize = (LPCSTR)(_bstr_t)(varFileSize);
		}
		listctrl.SetItemText(i,2,strFileSize);

		_variant_t varState = m_pRecordset->GetCollect("State");
		if(varState.vt != VT_NULL)
		{
			strState = (LPCSTR)(_bstr_t)(varState);
		}
		listctrl.SetItemText(i,3,strState);

		_variant_t varSendTime = m_pRecordset->GetCollect("SendTime");
		if(varSendTime.vt != VT_NULL)
		{
			strSendTime = (LPCSTR)(_bstr_t)(varSendTime);
		}
		listctrl.SetItemText(i,4,strSendTime);

		_variant_t varPassTime = m_pRecordset->GetCollect("PassTime");
		if(varPassTime.vt != VT_NULL)
		{
			strPassTime = (LPCSTR)(_bstr_t)(varPassTime);
		}
		listctrl.SetItemText(i,5,strPassTime);

		i++;
		m_pRecordset->MoveNext();
	}
}

void CNews::ShowListByNewsID(CListCtrl& listctrl,int iNewsID)
{
	int i=0;
    LV_ITEM lvitem;
	lvitem.mask=LVIF_TEXT | LVIF_IMAGE | LVIF_STATE;
	lvitem.state=0;
	lvitem.stateMask=0;

	CString strID;
	CString strTitle;
	CString strFileName;
	CString strFileSize;
	CString strSendTime;
	CString strPassTime;
	CString strState;
	CString strReporter;
	CString strChannel;
	CString strColumn;
	CString strMustAudit;


	//设置SELECT语句
	CString strNewsID;
	strNewsID.Format("%d",iNewsID);
	vSQL = "SELECT News.UID as NewsID,Title,FileName,FileSize,State,SendTime,PassTime,Users.Name as UserName,Channel.Name as ChannelName,Columns.Name as ColumnName,MustAuditID ";
	vSQL = vSQL + " FROM News, Users, Columns, Channel WHERE News.IsDelete= 0 AND Users.IsDelete= 0 AND Columns.IsDelete= 0 AND Channel.IsDelete= 0  ";
	vSQL = vSQL + " AND News.UserID = Users.UID AND News.ChannelID = Channel.UID AND News.ColumnID= Columns.UID AND News.UID="+strNewsID;
	
	//执行SELETE语句
	m_pRecordset = GetRecordSet(vSQL);
    
	 while(!m_pRecordset->adoEOF)
	{   
		lvitem.iItem=i;
		lvitem.iSubItem=0;

		_variant_t varID = m_pRecordset->GetCollect("NewsID");
		if(varID.vt != VT_NULL)
		{
			strID = (LPCSTR)(_bstr_t)(varID);
		}
		lvitem.pszText=(LPTSTR)(LPCTSTR)strID; 
		listctrl.InsertItem(&lvitem);

		_variant_t varTitle = m_pRecordset->GetCollect("Title");
		if(varTitle.vt != VT_NULL)
		{
			strTitle = (LPCSTR)(_bstr_t)(varTitle);
		}
		listctrl.SetItemText(i,1,strTitle);
		
		_variant_t varFileName= m_pRecordset->GetCollect("FileName");
		if(varFileName.vt != VT_NULL)
		{
			strFileName = (LPCSTR)(_bstr_t)(varFileName);
		}
		listctrl.SetItemText(i,2,strFileName);

		_variant_t varFileSize = m_pRecordset->GetCollect("FileSize");
		if(varFileSize.vt != VT_NULL)
		{
			strFileSize = (LPCSTR)(_bstr_t)(varFileSize);
		}
		listctrl.SetItemText(i,3,strFileSize);

		_variant_t varState = m_pRecordset->GetCollect("State");
		if(varState.vt != VT_NULL)
		{
			int itemp = atoi((LPCSTR)(_bstr_t)(varState));
			switch(itemp) 
			{ 
				case 0: 
					strState = "审核通过";
				break; 
				case 1: 
					strState = "待审核";
				break; 
				case 2: 
					strState = "审核未通过";
				break; 
				case 3: 
					strState = "审核中";
				break; 
				default: ; 
			} 

			 
		}
		listctrl.SetItemText(i,4,strState);

		_variant_t varSendTime = m_pRecordset->GetCollect("SendTime");
		if(varSendTime.vt != VT_NULL)
		{
			strSendTime = (LPCSTR)(_bstr_t)(varSendTime);
		}
		listctrl.SetItemText(i,5,strSendTime);

		_variant_t varPassTime = m_pRecordset->GetCollect("PassTime");
		if(varPassTime.vt != VT_NULL)
		{
			strPassTime = (LPCSTR)(_bstr_t)(varPassTime);
		}
		listctrl.SetItemText(i,6,strPassTime);

		_variant_t varReporter = m_pRecordset->GetCollect("UserName");
		if(varReporter.vt != VT_NULL)
		{
			strReporter = (LPCSTR)(_bstr_t)(varReporter);
		}
		listctrl.SetItemText(i,7,strReporter);

		_variant_t varChannel = m_pRecordset->GetCollect("ChannelName");
		if(varChannel.vt != VT_NULL)
		{
			strChannel = (LPCSTR)(_bstr_t)(varChannel);
		}
		listctrl.SetItemText(i,8,strChannel);

		_variant_t varColumn = m_pRecordset->GetCollect("ColumnName");
		if(varColumn.vt != VT_NULL)
		{
			strColumn = (LPCSTR)(_bstr_t)(varColumn);
		}
		listctrl.SetItemText(i,9,strColumn);

		_variant_t varMustAudit = m_pRecordset->GetCollect("MustAuditID");
		if(varMustAudit.vt != VT_NULL)
		{
			CString strtemp;
			strtemp = (LPCSTR)(_bstr_t)(varMustAudit);
			if(strtemp=="0")
			{
				strMustAudit="无";
			}
			else
			{
			
				vSQL = "SELECT Name FROM  Users WHERE IsDelete= 0 AND UID="+strtemp;
	
				//执行SELETE语句
				m_pRecordset = GetRecordSet(vSQL);
				_variant_t varName = m_pRecordset->GetCollect("Name");
				if(varName.vt != VT_NULL)
				{
					strMustAudit = (LPCSTR)(_bstr_t)(varName);
				}
			
			}
		}
		listctrl.SetItemText(i,10,strMustAudit);

		i++;
		m_pRecordset->MoveNext();
	}
}
void CNews::GetServerInfByNewsID(int iUID,CString& FileName,unsigned short& Port,CString& strIP)
{

	CString strUID;
	strUID.Format("%d", iUID);
	//设置SELECT语句
	vSQL = "SELECT FilePath,Port,ServerPC.IPStr AS IPStr FROM ServerPC,News WHERE ServerPC.IsDelete = 0 AND ServerPC.IPStr = News.IPStr AND News.UID = "+strUID;
	//执行SELETE语句

	m_pRecordset = GetRecordSet(vSQL);
	if (m_pRecordset->adoEOF)
	{
		Port=0;
		FileName="";
		strIP="";
	}
	else
	{
		Port = atoi((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("Port"));	
		FileName = (LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("FilePath");
		strIP = (LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("IPStr");
	}
}
//PASS
int CNews::getUIDByTitle(CString title)
{
	//设置SELECT语句
	
	vSQL = "SELECT UID FROM News WHERE Title='"+title+"'";
	//执行SELETE语句

	m_pRecordset = GetRecordSet(vSQL);
	if (m_pRecordset->adoEOF)
	{
		CNews();
	}
	else
	{
		UID = atoi((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("UID"));	
	}
	return UID;
}
void CNews::UploadNews(CString cTitle,long iUserID,long iColumnID,CString cDesc,CString cFileName,long iFileSize,long iAuditUserID,long IsAgent,CString cFilePath,long& iFlag,CString& cMessage)
{

⌨️ 快捷键说明

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