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

📄 userview.cpp

📁 人员管理子系统
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// USERView.cpp : implementation of the CUSERView class
//

#include "stdafx.h"
#include "USER.h"
#include "DialogUser.h"
#include "USERSet.h"
#include "USERDoc.h"
#include "USERView.h"
#include "PicdetailSet.h"
#include "DelDialog.h"

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

/////////////////////////////////////////////////////////////////////////////
// CUSERView

IMPLEMENT_DYNCREATE(CUSERView, CRecordView)

BEGIN_MESSAGE_MAP(CUSERView, CRecordView)
	//{{AFX_MSG_MAP(CUSERView)
	ON_BN_CLICKED(IDC_USER, OnUser)
	ON_COMMAND(ID_MENUADDUSER, OnMenuadduser)
	ON_COMMAND(ID_MENUDELUSER, OnMenudeluser)
	ON_COMMAND(ID_MENUEDITUSER, OnMenuedituser)
	ON_WM_PAINT()
	ON_NOTIFY(NM_DBLCLK, IDC_USERLIST, OnDblclkUserlist)
	ON_COMMAND(ID_MENULOCK, OnMenulock)
	ON_COMMAND(ID_MENUREPASSWORD, OnMenurepassword)
	//}}AFX_MSG_MAP
	// Standard printing commands
	ON_COMMAND(ID_FILE_PRINT, CRecordView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CRecordView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CRecordView::OnFilePrintPreview)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CUSERView construction/destruction

CUSERView::CUSERView()
	: CRecordView(CUSERView::IDD)
{
	//{{AFX_DATA_INIT(CUSERView)
	m_pSet = NULL;
	m_pInitialFlag=0;
	flag=0;
//	m_bmp=new CBmpProc();
	//}}AFX_DATA_INIT
	// TODO: add construction code here
    m_bmp=new CBmpProc();
}

CUSERView::~CUSERView()
{
//	delete m_bmp;
}

void CUSERView::DoDataExchange(CDataExchange* pDX)
{
	CRecordView::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CUSERView)
	DDX_Control(pDX, IDC_USERLIST, m_pList);
	//}}AFX_DATA_MAP
}

BOOL CUSERView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs
    CLogDialog dialog;
	if(dialog.DoModal()==IDCANCEL)
	{
	//	PostMessage(WM_CLOSE,0,0);
		return 0;
	}
	else
	{
		if(dialog.flag==0)
			return 0;
		m_pPassword=dialog.password;
	}
	return CRecordView::PreCreateWindow(cs);
}

void CUSERView::OnInitialUpdate()
{   
	
	if(m_pInitialFlag==0)
	{
		m_pSet = &GetDocument()->m_uSERSet;
		m_pSet2 = &GetDocument()->m_RoleSet;
		m_pSet2->m_pDatabase=m_pSet->m_pDatabase;
		CRecordView::OnInitialUpdate();
		GetParentFrame()->RecalcLayout();
		ResizeParentToFit();

		m_pList.SetExtendedStyle(LVS_EX_FULLROWSELECT);
		m_pList.SetTextBkColor(RGB(186,220,187));
		m_pList.SetBkColor(RGB(186,220,187));
		m_pList.SetTextColor(RGB(0,0,0));
		
		m_pList.InsertColumn(0,"用户英文名",LVCFMT_LEFT,100);
		m_pList.InsertColumn(1,"用户中文名",LVCFMT_LEFT,100);
		m_pList.InsertColumn(2,"用户部门",LVCFMT_LEFT,100);
		m_pInitialFlag=1;
	}
	else
	{
	m_pList.DeleteAllItems();
//	m_pList.SetCurSel(0);
	
	CString str="select userdepartment from userlist order by userdepartment";
	m_pSet->m_pDatabase->ExecuteSQL(str);
	m_pSet->MoveFirst();
	for(int i=0;i<m_pSet->GetRecordCount();i++)
	{
		CString strText;
	//	strText.Format(TEXT("item %d"), i);
		strText=m_pSet->m_userename;
		m_pList.InsertItem(LVIF_TEXT|LVIF_STATE,
			i,strText, 
			(i%2)==0 ? LVIS_SELECTED : 0, LVIS_SELECTED,
			0, 0);
		for (int j=1;j < m_pList.GetHeaderCtrl()->GetItemCount();j++)
		{
		//	strText.Format(TEXT("sub-item %d %d"), i, j);
			if(j==1)
				strText=m_pSet->m_usercname;
			else
				strText=m_pSet->m_userdepartment;
		    m_pList.SetItemText(i, j, strText);
		}

	//	m_pList.InsertItem(i,m_pSet->m_userename+"        "+m_pSet->m_usercname+"              "+m_pSet->m_userdepartment);
		m_pSet->MoveNext();
	}
	m_pSet->MoveFirst();
	}
}

/////////////////////////////////////////////////////////////////////////////
// CUSERView printing

BOOL CUSERView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}

void CUSERView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

void CUSERView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

/////////////////////////////////////////////////////////////////////////////
// CUSERView diagnostics

#ifdef _DEBUG
void CUSERView::AssertValid() const
{
	CRecordView::AssertValid();
}

void CUSERView::Dump(CDumpContext& dc) const
{
	CRecordView::Dump(dc);
}

CUSERDoc* CUSERView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CUSERDoc)));
	return (CUSERDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CUSERView database support
CRecordset* CUSERView::OnGetRecordset()
{
	return m_pSet;
}


/////////////////////////////////////////////////////////////////////////////
// CUSERView message handlers

void CUSERView::OnUser() 
{
/*	CString str1;
	CString str2="adsfasdf";
	CString str3="adsfasdff";
	str1=str2;
	str1=str3;*/
	// TODO: Add your control notification handler code here
//	m_pList.SetTextBkColor(RGB(0,255,0));
//	m_pList.SetTextColor(RGB(255,0,0));
	m_pList.DeleteAllItems();
//	m_pList.SetCurSel(0);
//	int j=m_pSet->GetRecordCount();
	
	if(m_pSet->GetRecordCount())
	{
		CString str="select userdepartment from userlist order by userdepartment";
		m_pSet->m_pDatabase->ExecuteSQL(str);
		m_pSet->MoveFirst();
		for(int i=0;i<m_pSet->GetRecordCount();i++)
		{
			CString strText;
	//	strText.Format(TEXT("item %d"), i);
			strText=m_pSet->m_userename;
			m_pList.InsertItem(LVIF_TEXT|LVIF_STATE,
				i,strText, 
				(i%2)==0 ? LVIS_SELECTED : 0, LVIS_SELECTED,
				0, 0);
			for (int j=1;j < m_pList.GetHeaderCtrl()->GetItemCount();j++)
			{
		//	strText.Format(TEXT("sub-item %d %d"), i, j);
				if(j==1)
					strText=m_pSet->m_usercname;
				else
					strText=m_pSet->m_userdepartment;
			  m_pList.SetItemText(i, j, strText);
			}

	//	m_pList.InsertItem(i,m_pSet->m_userename+"        "+m_pSet->m_usercname+"              "+m_pSet->m_userdepartment);
			m_pSet->MoveNext();
		}
		m_pSet->MoveFirst();
	}
	
//	UpdateData(false);
}

/*void CUSERView::OnOk() 
{
	// TODO: Add your control notification handler code here

	int temp=m_pList.GetItemCount();
//	temp++;
//	m_pSet->MoveFirst();
	m_pSet->SetAbsolutePosition(((long)temp));
	int userrole=m_pSet->m_userrole;
	m_pSet2->Open();
	for(int i=0;i<m_pSet2->GetRecordCount();i++)
	{
		if(m_pSet2->m_roleID==userrole)
		{
			m_pRole=m_pSet2->m_roledescribe;
		}
		else
		{
			m_pSet2->MoveNext();
		}
	}
	UpdateData(false);

	CPicdetailSet *m_pPic=new CPicdetailSet(m_pSet->m_pDatabase);
	m_pPic->Open();
	m_pPic->MoveFirst();
	for(int p=0;p<m_pPic->GetRecordCount();p++)
	{
		if(m_pPic->m_picdetail.m_dwDataLength>50)
		{
		//	AfxMessageBox("asdfsa");
			
			
		//	int temp=m_pSet->m_usermark.m_dwDataLength;
			int temp=m_pPic->m_picdetail.m_dwDataLength;
			char pstring[56];
			DWORD length=56;
			GetCurrentDirectory(length,pstring);
		
			CString strFileName=pstring;
			strFileName=strFileName+"\\Forest4.bmp";
			CFile outFile(strFileName,CFile::modeCreate|CFile::modeWrite); 
			LPSTR buffer = (LPSTR)GlobalLock(m_pPic->m_picdetail.m_hData);
			outFile.WriteHuge(buffer,m_pPic->m_picdetail.m_dwDataLength);
			GlobalUnlock(m_pPic->m_picdetail.m_hData);
			outFile.Close(); 
		}
		m_pPic->MoveNext();
	}
	m_pPic->Close();
	delete m_pPic;

	m_pSet->MoveFirst();
	for(int p=0;p<m_pSet->GetRecordCount();p++)
	{
		if(m_pSet->m_usermark.m_dwDataLength>50)
		{
		//	AfxMessageBox("asdfsa");
			
			
		//	int temp=m_pSet->m_usermark.m_dwDataLength;
			int temp=m_pSet->m_usermark.m_dwDataLength;
			char pstring[56];
			DWORD length=56;
			GetCurrentDirectory(length,pstring);
		
			CString strFileName=pstring;
			strFileName=strFileName+"\\Forest3.bmp";
			CFile outFile(strFileName,CFile::modeCreate|CFile::modeWrite); 
			LPSTR buffer = (LPSTR)GlobalLock(m_pSet->m_usermark.m_hData);
			outFile.WriteHuge(buffer,m_pSet->m_usermark.m_dwDataLength);
			GlobalUnlock(m_pSet->m_usermark.m_hData);
			outFile.Close(); 
		}
		m_pSet->MoveNext();
	}
//	m_pSet->Close();

//	m_pSet->SetRowsetCursorPosition(temp);
//	CDBVariant varValue;
//	m_pSet->GetFieldValue("userrole",varValue,DEFAULT_FIELD_TYPE);
//	int userrole=varValue.m_iVal;
}*/

void CUSERView::OnMenuadduser() 

⌨️ 快捷键说明

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