void CStaffManageView::OnBnClickedSetPhoto()
{
	CString strFilter = _T("BMP图像文件|*.bmp;*.dib||");

	CFileDialog     dlg(TRUE,NULL,NULL,0,strFilter,this);     
	if(dlg.DoModal()!=IDOK)
		return;

	//m_pSet->Edit();   //声明编辑当前记录 
	CFile     filePhoto;      
	CFileStatus     fileStatus;      
	CString     fileLocate = dlg.GetPathName();            
	filePhoto.Open(fileLocate,CFile::modeRead);           
	filePhoto.GetStatus(fileStatus);

	m_pSet->m_PtrPhoto.m_dwDataLength = (SQLUINTEGER)fileStatus.m_size;
	HGLOBAL     hGlobal     =     GlobalAlloc(GPTR,(SIZE_T)fileStatus.m_size);           
	m_pSet->m_PtrPhoto.m_hData     =     GlobalLock(hGlobal);
	filePhoto.Read(m_pSet->m_PtrPhoto.m_hData,(UINT)fileStatus.m_size);           

	//把您选择的文件的数据写入m_pSet-m_PtrPhoto           
	m_pSet->SetFieldDirty(&m_pSet->m_PtrPhoto);           

	m_pSet->SetFieldNull(&m_pSet->m_PtrPhoto,FALSE);           
	//m_pSet->Update();     //     更新记录           
	GlobalUnlock(hGlobal); 


	CWnd *pPictureWnd = GetDlgItem(IDC_STATIC_PHOTO);
	m_hPhotoBitmap = BufferToHBITMAP(pPictureWnd,(char*)m_pSet->m_PtrPhoto.m_hData);
	this->RedrawWindow();
}
Beispiel #2
0
BOOL IsExist(LPCTSTR strPath)
{
	CFile file;																						
	CFileStatus status;

	return file.GetStatus(strPath, status);
}
Beispiel #3
0
bool EVUtil::ODBCInsertOLEImage( EVRecord rec,CString strName )
{
	if(m_db.IsOpen())
	{
		CdbImages rs(&m_db);
		rs.Open();
		if(rs.IsOpen())
		{
			rs.AddNew();
			CFile fileword;
			CFileStatus fileStatus; 
			fileword.Open(strName,CFile::modeRead); 
			fileword.GetStatus(fileStatus); 
			HGLOBAL hGlobal		= GlobalAlloc(GPTR,(SIZE_T)fileStatus.m_size);
			rs.m_BLOBImage.m_hData = GlobalLock(hGlobal);
			fileword.Read(rs.m_BLOBImage.m_hData,(UINT)fileStatus.m_size); 
			rs.m_BLOBImage.m_dwDataLength=(SQLULEN)fileStatus.m_size;
			rs.m_szID = rec.m_szID;
			rs.m_szName = rec.m_szName;
			rs.m_szArea = rec.m_szArea;
			rs.m_szOther=rec.m_szOther;
			{
				rec.m_szDate.TrimLeft();
				rec.m_szDate.TrimRight();
				if(!rs.m_szDate.ParseDateTime(rec.m_szDate))
				{
					int a=0,b=0,c=0;   
					sscanf(rec.m_szDate.GetBuffer(rec.m_szDate.GetLength()),"%d年%d月%d日",&a,&b,&c);   
					rs.m_szDate.SetDate(a,b,c);			
				}
				rec.m_szCreateTime.TrimLeft();
				rec.m_szCreateTime.TrimRight();
				if(!rs.m_szCreateTime.ParseDateTime(rec.m_szCreateTime))
				{
					int a=0,b=0,c=0;   
					sscanf(rec.m_szCreateTime.GetBuffer(rec.m_szCreateTime.GetLength()),"%d年%d月%d日",&a,&b,&c);   
					rs.m_szCreateTime.SetDate(a,b,c);			
				}
			}
			rs.m_szInfo = rec.m_szInfo;
			rs.m_b1=rec.m_bMetal;
			rs.m_b2 = rec.m_bPos;
			rs.m_b3 = rec.m_bDirect;
			rs.m_b4= rec.m_bMark;
			rs.m_bOut = FALSE;
			rs.m_szPointData = rec.m_szPointData;
			rs.SetFieldDirty(&rs.m_BLOBImage,TRUE);
			rs.SetFieldDirty(&rs.m_szPointData);
			rs.SetFieldNull (&rs.m_BLOBImage,NULL);
			rs.Update();
			GlobalUnlock(hGlobal);
		}
		rs.Close();
		return true;
	}
	return false;
}
Beispiel #4
0
bool EVUtil::ODBCUpdateOLEImage( int iID,CString strName )
{
	if ( strName.GetLength()<1 )
	{
		return false;
	}
	if(m_db.IsOpen())
	{
		CdbImages rs(&m_db);
		rs.Open();
		if(rs.IsOpen())
		{
			rs.MoveFirst();
			while(!rs.IsEOF())
			{
				if ( rs.m_iID!=iID )
				{
					rs.MoveNext();
					continue;
				}
				rs.Edit();

				CFile fileword;
				CFileStatus fileStatus; 
				fileword.Open(strName,CFile::modeRead); 
				fileword.GetStatus(fileStatus); 
				HGLOBAL hGlobal		= GlobalAlloc(GPTR,(size_t)fileStatus.m_size);
				rs.m_BLOBImage.m_hData = GlobalLock(hGlobal);
				fileword.Read(rs.m_BLOBImage.m_hData,(UINT)fileStatus.m_size); 
				rs.m_BLOBImage.m_dwDataLength=(SQLULEN)fileStatus.m_size;
				rs.SetFieldDirty(&rs.m_BLOBImage,TRUE);
				rs.SetFieldNull (&rs.m_BLOBImage,NULL);
				rs.Update();
				GlobalUnlock(hGlobal);

				break;
			}
		}
		rs.Close();
		return true;
	}
	return false;
}
Beispiel #5
0
bool EVUtil::ODBCSetOLEImage( int iID,CString strName )
{
	if(m_db.IsOpen())
	{
		CString sql;
		sql.Format(_T("select * FROM 数据 WHERE ID = %d"),iID);
		CdbImages rs(&m_db);
		rs.Open();
		if(rs.IsOpen())
		{
			rs.MoveFirst();
			while(!rs.IsEOF())
			{
				if ( rs.m_iID!=iID )
				{
					rs.MoveNext();
					continue;
				}
				rs.Edit();
				CFile fileword;
				CFileStatus fileStatus; 
				fileword.Open(strName,CFile::modeRead); 
				fileword.GetStatus(fileStatus); 
				HGLOBAL hGlobal		= GlobalAlloc(GPTR,(SIZE_T)fileStatus.m_size);
				rs.m_BLOBImage.m_hData = GlobalLock(hGlobal);
				fileword.Read(rs.m_BLOBImage.m_hData,(UINT)fileStatus.m_size); 
				rs.m_BLOBImage.m_dwDataLength=(SQLULEN)fileStatus.m_size;
				rs.SetFieldDirty(&rs.m_BLOBImage,TRUE);
				rs.SetFieldNull (&rs.m_BLOBImage,NULL);
				rs.Update();
				GlobalUnlock(hGlobal);
				rs.Close();
				return true;
			}
			rs.Close();
		}
	}

	return false;
}
Beispiel #6
0
//reads ini file specified using CIniFile::SetPath()
//returns true if successful, false otherwise
CString CIniFile::ReadFile(CString filename)
{
	CFile file;
	CFileStatus status;
	if (!file.GetStatus(filename,status))
		return "Ooops";//by ny
	ifstream inifile;
	CString readinfo;
	inifile.open(filename);
	int curkey = -1, curval = -1;
	if (inifile.fail())
	{
		error = "Unable to open ini file.";
		return "Unable to open ini file.";//by ny
	}
	CString keyname, valuename, value;
	CString temp;
	while (getline(inifile,readinfo))
	{
		if (readinfo != "")
		{
			if (readinfo[0] == '[' && readinfo[readinfo.GetLength()-1] == ']') //if a section heading
			{
				keyname = readinfo;
				keyname.TrimLeft('[');
				keyname.TrimRight(']');
			}
			else //if a value
			{
				valuename = readinfo.Left(readinfo.Find("="));
				value = readinfo.Right(readinfo.GetLength()-valuename.GetLength()-1);
				SetValue(keyname,valuename,value);
			}
		}
	}
	inifile.close();
	return valuename;
}