📄 servfiles.cpp
字号:
// ServFiles.cpp: implementation of the CServFiles class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "tvnews.h"
#include "ServFiles.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CServFiles::CServFiles()
{
}
CServFiles::~CServFiles()
{
}
int CServFiles::GetPort()
{
return Port;
}
void CServFiles::SetPort(int iPort)
{
Port=iPort;
}
CString CServFiles::GetIPStr()
{
return IPStr;
}
CString CServFiles::GetFilePath()
{
return FilePath;
}
int CServFiles::GetUID()
{
return UID;
}
int CServFiles::GetUserID()
{
return UserID;
}
int CServFiles::GetChannelID()
{
return ChannelID;
}
CString CServFiles::GetFileName()
{
return FileName;
}
int CServFiles::GetFileSize()
{
return FileSize;
}
CString CServFiles::GetSendTime()
{
return SendTime;
}
int CServFiles::GetState()
{
return State;
}
int CServFiles::GetIsDelete()
{
return IsDelete;
}
int CServFiles::GetType()
{
return Type;
}
int CServFiles::GetPriority()
{
return Priority;
}
void CServFiles::SetUID(int iUID)
{
UID=iUID;
}
void CServFiles::SetUserID(int iUserID)
{
UserID=iUserID;
}
void CServFiles::SetChannelID(int iChannelID)
{
ChannelID=iChannelID;
}
void CServFiles::SetFileName(CString cFileName)
{
FileName=cFileName;
}
void CServFiles::SetFileSize(int iFileSize)
{
FileSize=iFileSize;
}
void CServFiles::SetSendTime(CString cSendTime)
{
SendTime=cSendTime;
}
void CServFiles::SetState(int iState)
{
State=iState;
}
void CServFiles::SetIsDelete(int cIsDelete)
{
IsDelete=cIsDelete;
}
void CServFiles::SetIPStr(CString cIPStr)
{
IPStr=cIPStr;
}
void CServFiles::SetFilePath(CString cFilePath)
{
FilePath=cFilePath;
}
void CServFiles::GetType(int iType)
{
Type=iType;
}
void CServFiles::GetPriority(int iPriority)
{
Priority=iPriority;
}
void CServFiles::GetData(int UID)
{
//设置SELECT语句
CString strUID;
strUID.Format("%d",UID);
vSQL = "SELECT UserID,ChannelID,FileName,FilePath,FileSize,SendTime,State,a.IPStr as IPStr,Port FROM News a,ServerPC b WHERE a.IsDelete = 0 AND b.IsDelete = 0 AND a.IPStr=b.IPStr AND a.UID=" + strUID;
//执行SELETE语句
m_pRecordset = GetRecordSet(vSQL);
//返回各列的值
if (m_pRecordset->adoEOF)
CServFiles();
else
{
UserID = atoi((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("UserID"));
ChannelID = atoi((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("ChannelID"));
FileName = (LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("FileName");
FilePath = (LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("FilePath");
FileSize = atoi((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("FileSize"));
SendTime = (LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("SendTime");
State = atoi((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("State"));
IPStr = (LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("IPStr");
Port = atoi((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("Port"));
}
}
void CServFiles::DelFile(long NewsID,long& iFlg,CString& cMessage)
{
try
{
m_pCommand.CreateInstance(__uuidof(Command));
m_pCommand->ActiveConnection=m_pConnection;
m_pCommand->CommandType=adCmdStoredProc;
m_pCommand->CommandText=_bstr_t("del_File");
_variant_t vvar1,vvar2,vvar3;
vvar1=_variant_t(NewsID);
vvar2=_variant_t(iFlg);
vvar3=_variant_t(_bstr_t(cMessage));
_ParameterPtr mp_var1,mp_var2,mp_var3;
mp_var1.CreateInstance(__uuidof(Parameter));
mp_var2.CreateInstance(__uuidof(Parameter));
mp_var3.CreateInstance(__uuidof(Parameter));
mp_var1=m_pCommand->CreateParameter
(
_bstr_t("var1"),
adBigInt,
adParamInput,
5,
vvar1
);
m_pCommand->Parameters->Append(mp_var1);
mp_var2=m_pCommand->CreateParameter
(
_bstr_t("var2"),
adBigInt,
adParamOutput,
5,
vvar2
);
m_pCommand->Parameters->Append(mp_var2);
mp_var3=m_pCommand->CreateParameter
(
_bstr_t("var3"),
adVarChar,
adParamOutput,
200,
vvar3
);
m_pCommand->Parameters->Append(mp_var3);
_variant_t vNull;
vNull.vt=VT_ERROR;
vNull.scode=DISP_E_PARAMNOTFOUND;
m_pCommand->Execute(&vNull,&vNull,adCmdStoredProc);
iFlg=mp_var2->Value;
cMessage=mp_var3->Value.bstrVal;
}
catch(_com_error &error)
{
AfxMessageBox(error.ErrorMessage(),MB_OK,0);
AfxMessageBox(error.Description(),MB_OK,0);
AfxMessageBox("ADO错误!",MB_OK,0);
}
}
void CServFiles::ShowList(CListCtrl& listctrl,CString cCondition)
{
int i=0;
LV_ITEM lvitem;
lvitem.mask=LVIF_TEXT | LVIF_IMAGE | LVIF_STATE;
lvitem.state=0;
lvitem.stateMask=0;
CString strUID,strFileName,strSendTime,strStateName,strChannelName,strUserName,strFileSize,strTypeName,strPriorityName;
listctrl.DeleteAllItems();
m_pCommand.CreateInstance(__uuidof(Command));
m_pCommand->ActiveConnection=m_pConnection;
m_pCommand->CommandText="QryFile";
m_pCommand->CommandType=adCmdStoredProc;
m_pCommand->Parameters->Refresh();
m_pCommand->Parameters->GetItem((short)1)->Value=(_bstr_t)cCondition;
m_pRecordset = m_pCommand->Execute(NULL,NULL,adCmdStoredProc);
while(!m_pRecordset->adoEOF)
{
lvitem.iItem=i;
lvitem.iSubItem=0;
strUID=(LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("UID");
lvitem.pszText=(LPTSTR)(LPCTSTR)strUID;
listctrl.InsertItem(&lvitem);
strFileName =(LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("FileName");
listctrl.SetItemText(i,1,strFileName);
strSendTime =(LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("SendTime");
listctrl.SetItemText(i,2,strSendTime);
strStateName =(LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("StateName");
listctrl.SetItemText(i,3,strStateName);
strChannelName =(LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("ChannelName");
listctrl.SetItemText(i,4,strChannelName);
strUserName =(LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("UserName");
listctrl.SetItemText(i,5,strUserName);
strFileSize =(LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("FileSize");
listctrl.SetItemText(i,6,strFileSize);
strTypeName =(LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("TypeName");
listctrl.SetItemText(i,7,strTypeName);
strPriorityName =(LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("PriorityName");
listctrl.SetItemText(i,8,strPriorityName);
i++;
m_pRecordset->MoveNext();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -