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

📄 users.cpp

📁 一个电视台专用的信息管理软件源代码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
		m_pCommand->Parameters->Append(mp_var9); 


		_variant_t vNull;
		vNull.vt=VT_ERROR;
		vNull.scode=DISP_E_PARAMNOTFOUND;
		m_pCommand->Execute(&vNull,&vNull,adCmdStoredProc);

		iFlg=mp_var8->Value;
		cMessage=mp_var9->Value.bstrVal;
		}
		catch(_com_error &error)
		{
			AfxMessageBox(error.ErrorMessage(),MB_OK,0);
			AfxMessageBox(error.Description(),MB_OK,0);
			AfxMessageBox("ADO错误!",MB_OK,0);
		}

}

void CUsers::update(long iUID,CString cLoginName,CString cPwd,CString cName,CString cSex,long iRoleID,long iChannelID,long iColumnID,long& iFlg,CString& cMessage)
{
	try
	{
		m_pCommand.CreateInstance(__uuidof(Command));
		m_pCommand->ActiveConnection=m_pConnection;
		m_pCommand->CommandType=adCmdStoredProc;
		m_pCommand->CommandText=_bstr_t("edt_Users");
		
		_variant_t vvar1,vvar2,vvar3,vvar4,vvar5,vvar6,vvar7,vvar8,vvar9,vvar10;
	
		vvar1=_variant_t(_bstr_t(cLoginName));
		vvar2=_variant_t(_bstr_t(cPwd));
		vvar3=_variant_t(_bstr_t(cName));
		vvar4=_variant_t(_bstr_t(cSex));
		vvar5=_variant_t(iRoleID);
		vvar6=_variant_t(iChannelID);
		vvar7=_variant_t(iColumnID);
		vvar8=_variant_t(iUID);
		vvar9=_variant_t(iFlg);
		vvar10=_variant_t(_bstr_t(cMessage));

		_ParameterPtr mp_var1,mp_var2,mp_var3,mp_var4,mp_var5,mp_var6,mp_var7,mp_var8,mp_var9,mp_var10;
		mp_var1.CreateInstance(__uuidof(Parameter));
		mp_var2.CreateInstance(__uuidof(Parameter));
		mp_var3.CreateInstance(__uuidof(Parameter));
		mp_var4.CreateInstance(__uuidof(Parameter));
		mp_var5.CreateInstance(__uuidof(Parameter));
		mp_var6.CreateInstance(__uuidof(Parameter));
		mp_var7.CreateInstance(__uuidof(Parameter));
		mp_var8.CreateInstance(__uuidof(Parameter));
		mp_var9.CreateInstance(__uuidof(Parameter));
		mp_var10.CreateInstance(__uuidof(Parameter));
	
		mp_var1=m_pCommand->CreateParameter
		(
		_bstr_t("var1"),
		adVarChar,
		adParamInput,
		20,
		vvar1
		);
		m_pCommand->Parameters->Append(mp_var1); 

		mp_var2=m_pCommand->CreateParameter
		(
		_bstr_t("var2"),
		adVarChar,
		adParamInput,
		20,
		vvar2
		);
		m_pCommand->Parameters->Append(mp_var2); 

		mp_var3=m_pCommand->CreateParameter
		(
		_bstr_t("var3"),
		adVarChar,
		adParamInput,
		20,
		vvar3
		);
		m_pCommand->Parameters->Append(mp_var3); 

		mp_var4=m_pCommand->CreateParameter
		(
		_bstr_t("var4"),
		adVarChar,
		adParamInput,
		1,
		vvar4
		);
		m_pCommand->Parameters->Append(mp_var4); 
		
		mp_var5=m_pCommand->CreateParameter
		(
		_bstr_t("var5"),
		adBigInt,
		adParamInput,
		5,
		vvar5
		);
		m_pCommand->Parameters->Append(mp_var5); 
	
		mp_var6=m_pCommand->CreateParameter
		(
		_bstr_t("var6"),
		adBigInt,
		adParamInput,
		5,
		vvar6
		);
		m_pCommand->Parameters->Append(mp_var6); 

		mp_var7=m_pCommand->CreateParameter
		(
		_bstr_t("var7"),
		adBigInt,
		adParamInput,
		5,
		vvar7
		);
		m_pCommand->Parameters->Append(mp_var7); 

		mp_var8=m_pCommand->CreateParameter
		(
		_bstr_t("var8"),
		adBigInt,
		adParamInput,
		5,
		vvar8
		);
		m_pCommand->Parameters->Append(mp_var8); 
	
		mp_var9=m_pCommand->CreateParameter
		(
		_bstr_t("var9"),
		adBigInt,
		adParamOutput,
		5,
		vvar9
		);
		m_pCommand->Parameters->Append(mp_var9); 

		mp_var10=m_pCommand->CreateParameter
		(
		_bstr_t("var10"),
		adVarChar,
		adParamOutput,
		200,
		vvar10
		);
		m_pCommand->Parameters->Append(mp_var10); 


		_variant_t vNull;
		vNull.vt=VT_ERROR;
		vNull.scode=DISP_E_PARAMNOTFOUND;
		m_pCommand->Execute(&vNull,&vNull,adCmdStoredProc);

		iFlg=mp_var9->Value;
		cMessage=mp_var10->Value.bstrVal;
		}
		catch(_com_error &error)
		{
			AfxMessageBox(error.ErrorMessage(),MB_OK,0);
			AfxMessageBox(error.Description(),MB_OK,0);
			AfxMessageBox("ADO错误!",MB_OK,0);
		}

}

	


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

	CString strUID,strLoginName,strPassword,strName,strSex,strRoleID;
	CString strChannelID,strColumnID;
	listctrl.DeleteAllItems();

	m_pCommand.CreateInstance(__uuidof(Command));
	m_pCommand->ActiveConnection=m_pConnection;
	m_pCommand->CommandText="QryUser";    
	m_pCommand->CommandType=adCmdStoredProc;
	m_pCommand->Parameters->Refresh(); 

	m_pCommand->Parameters->GetItem((short)1)->Value=(_bstr_t)strSQL;


	m_pRecordset = m_pCommand->Execute(NULL,NULL,adCmdStoredProc);
    
	
	 while(!m_pRecordset->adoEOF)
	{   
		lvitem.iItem=i;
		lvitem.iSubItem=0;
		if(atoi((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("IsLog"))==1)
		{
			listctrl.SetTextColor(RGB(255,0,0));
		}
		else
		{
			listctrl.SetTextColor(RGB(0,0,0));
		}
		strUID=(LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("iUID");
		lvitem.pszText=(LPTSTR)(LPCTSTR)strUID;  
		listctrl.InsertItem(&lvitem);

		strLoginName =(LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("LoginName");
		listctrl.SetItemText(i,1,strLoginName);

		strPassword =(LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("Password");
		listctrl.SetItemText(i,2,strPassword);

		strName =(LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("Name");
		listctrl.SetItemText(i,3,strName);

		strSex =(LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("Sex");
		listctrl.SetItemText(i,4,strSex);

		strRoleID =(LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("RoleName");
		listctrl.SetItemText(i,5,strRoleID);

		strChannelID =(LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("ChannelName");
		listctrl.SetItemText(i,6,strChannelID);

		strColumnID =(LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("ColumnName");
		listctrl.SetItemText(i,7,strColumnID);

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

}
void CUsers::GetNames(CStringArray& allNames,CString strSQL)
{
	//设置SELECT语句
	vSQL = "SELECT * FROM Users,UserChannel WHERE UserChannel.UserID = Users.UID AND Users.IsDelete = 0 AND UserChannel.IsDelete = 0 " + strSQL;
	//执行SELETE语句
	m_pRecordset = GetRecordSet(vSQL);
	while(!m_pRecordset->adoEOF)
	{
		allNames.Add(_T((_bstr_t)m_pRecordset->GetCollect("Name")));
		m_pRecordset->MoveNext();
	}

}
void CUsers::LogIn(long iUID,long& iFlg,CString& cMessage)
{
		try
	{
		m_pCommand.CreateInstance(__uuidof(Command));
		m_pCommand->ActiveConnection=m_pConnection;
		m_pCommand->CommandType=adCmdStoredProc;
		m_pCommand->CommandText=_bstr_t("UserLog");
		
		_variant_t vvar1,vvar2,vvar3;
	
		vvar1=_variant_t(iUID);
		
		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"),
		adVarChar,
		adParamInput,
		20,
		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 CUsers::LogOut(long iUID,long& iFlg,CString& cMessage)
{
	try
	{
		m_pCommand.CreateInstance(__uuidof(Command));
		m_pCommand->ActiveConnection=m_pConnection;
		m_pCommand->CommandType=adCmdStoredProc;
		m_pCommand->CommandText=_bstr_t("LogOut");
		
		_variant_t vvar1,vvar2,vvar3;
	
		vvar1=_variant_t(iUID);
		
		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"),
		adVarChar,
		adParamInput,
		20,
		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 CUsers::GetUsersInf(CStringArray& UsersInf)
{
	m_pCommand.CreateInstance(__uuidof(Command));
	m_pCommand->ActiveConnection=m_pConnection;
	m_pCommand->CommandText="QryUserNum";    
	m_pCommand->CommandType=adCmdStoredProc;
	m_pCommand->Parameters->Refresh(); 


	m_pRecordset = m_pCommand->Execute(NULL,NULL,adCmdStoredProc);
	
	 while(!m_pRecordset->adoEOF)
	{   
		UsersInf.Add("记者总人数:"+_T((_bstr_t)m_pRecordset->GetCollect("TolREP"))+",在线人数:"+_T((_bstr_t)m_pRecordset->GetCollect("InREP")));
		UsersInf.Add("责任编辑总人数:"+_T((_bstr_t)m_pRecordset->GetCollect("TolBJ"))+",在线人数:"+_T((_bstr_t)m_pRecordset->GetCollect("InBJ")));
		UsersInf.Add("频道总监总人数:"+_T((_bstr_t)m_pRecordset->GetCollect("TolZJ"))+",在线人数:"+_T((_bstr_t)m_pRecordset->GetCollect("InZJ")));
		UsersInf.Add("台长总人数:"+_T((_bstr_t)m_pRecordset->GetCollect("TolTZ"))+",在线人数:"+_T((_bstr_t)m_pRecordset->GetCollect("InTZ")));
		m_pRecordset->MoveNext();
	}
	

}

⌨️ 快捷键说明

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