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

📄 userview.cpp

📁 人员管理子系统
💻 CPP
📖 第 1 页 / 共 2 页
字号:
{
	// TODO: Add your command handler code here
	CUSERDoc* pDoc = GetDocument();

	CDialogUser dialog;
	dialog.flag=1;
/*	dialog.m_pClass=pDoc->m_pClass;
	dialog.m_pDepartment=pDoc->m_pDepartment;
	dialog.m_pDuty=pDoc->m_pDuty;
	dialog.m_pMark=pDoc->m_pMark;
	dialog.m_pRadio=pDoc->m_pRadio;
	dialog.m_pUserCName=pDoc->m_pUserCName;
	dialog.m_pUserEName=pDoc->m_pUserEName;
	dialog.m_UserMemo=pDoc->m_UserMemo;
	dialog.m_UserPassword=pDoc->m_UserPassword;
	dialog.m_UserPasswordR=pDoc->m_UserPasswordR;*/
	
//	dialog.m_pClass.ResetContent();
//	dialog.m_pDepartment.GetCount();

//	dialog.m_pClass.AddString(m_pSet->m_userdepartment);
//	dialog.m_pTemp=m_pSet->m_userdepartment;
	if(dialog.DoModal()==IDOK)
	{
	
		/*	if(dialog.m_UserPassword!=dialog.m_UserPasswordR)
			{
				AfxMessageBox("请重新核对您的密码");
				return;
			}
			else
			{
				if(dialog.m_pUserEName==""||dialog.m_pUserCName=="")
				{
					AfxMessageBox("用户名不能为空,请重新填写");
					return;
				}
			}*/
		
		pDoc->m_pClass=dialog.m_pClassStr;
		pDoc->m_pDepartment=dialog.m_pDepartmentStr;
		pDoc->m_pDuty=dialog.m_pDuty;
		pDoc->m_pMark=dialog.m_pMark;
		pDoc->m_pRadio=dialog.m_pRadio;
		pDoc->m_pUserCName=dialog.m_pUserCName;
		pDoc->m_pUserEName=dialog.m_pUserEName;
		pDoc->m_UserMemo=dialog.m_UserMemo;
		pDoc->m_UserPassword=dialog.m_UserPassword;
		pDoc->m_UserPasswordR=dialog.m_UserPasswordR;

		m_pSet->MoveLast();
		if(m_pSet->CanAppend())
		{
			m_pSet->AddNew();
		//	m_pSet->m_ID=m_pSet->GetRecordCount()+1;
			m_pSet->m_userename=pDoc->m_pUserEName;
			m_pSet->m_usercname=pDoc->m_pUserCName;
			m_pSet->m_userpassword=pDoc->m_UserPassword;
			m_pSet->m_userrole=pDoc->m_pRadio+1;
			m_pSet->m_userdepartment=pDoc->m_pDepartment;
			m_pSet->m_usergroup=pDoc->m_pClass;
			m_pSet->m_userduty=pDoc->m_pDuty;

			m_pSet->m_usermemo=pDoc->m_UserMemo;
	
	/*	char pstring[56];
		DWORD length=56;
		GetCurrentDirectory(length,pstring);
		CFile fileword;
		CFileStatus fileStatus;
		CString fileLocate=pstring;
			fileLocate=fileLocate+"\\Forest.bmp";*/
			if(pDoc->m_pMark!="")
			{
				CFile fileword;
				CFileStatus fileStatus;
				CString fileLocate=pDoc->m_pMark;
				fileword.Open(fileLocate,CFile::modeReadWrite);
				fileword.GetStatus(fileStatus);

				m_pSet->m_usermark.m_dwDataLength=fileStatus.m_size;
				HGLOBAL hGlobal = GlobalAlloc(GPTR,fileStatus.m_size);
				m_pSet->m_usermark.m_hData = GlobalLock(hGlobal);
				fileword.ReadHuge(m_pSet->m_usermark.m_hData,fileStatus.m_size); //把您选择的文件的数据写入m_pSet-〉m_REPORT 
				m_pSet->SetFieldDirty(&m_pSet->m_usermark);
				m_pSet->SetFieldNull(&m_pSet->m_usermark,FALSE);
				GlobalUnlock(hGlobal);
			}
//		m_pSet-〉Update(); // 更新记录
		m_pSet->Update();
		
		m_pSet->Requery();
		}
		UpdateData();
		OnInitialUpdate();
	}
	
}

void CUSERView::OnMenudeluser() 
{
	// TODO: Add your command handler code here
//	int temp=m_pList.GetItemPosition(nitem,&point);
	int i;
	for(i=0;i<m_pList.GetItemCount();i++)
	{
		if(m_pList.GetItemState(i,LVIS_SELECTED)==LVIS_SELECTED)
		{
		//	m_worknoteDlg.m_worknoteInfo->m_notenum=m_listctrl.GetItemText(i,0);
		//	m_worknoteDlg.m_notenum=m_listctrl.GetItemText(i,0);
		//	m_worknoteDlg.Name=m_listctrl.GetItemText(i,2);
		//	IsSelected=TRUE;
		    break;
		}
	}
	if(i<m_pList.GetItemCount())
	{
		CDelDialog dialog;
		if(dialog.DoModal()==IDOK)
		{
			int temp=m_pList.GetSelectionMark();
			temp++;
			m_pSet->SetAbsolutePosition(((long)temp));
//	int temp=m_pList.GetItemCount();
//	temp++;
//	m_pSet->SetAbsolutePosition(((long)temp));
			m_pSet->Delete();
	
//	m_pSet->Update();
			m_pSet->MoveNext();
			m_pSet->Requery();
			UpdateData();
			OnInitialUpdate();
		}
	}
	else
	{
		AfxMessageBox("请先选择您想删除的用户");
	}
}

void CUSERView::OnMenuedituser()
{
	// TODO: Add your command handler code here
//	int temp=m_pList.GetItemPosition(nitem,&point);
	int i;
	for(i=0;i<m_pList.GetItemCount();i++)
	{
		if(m_pList.GetItemState(i,LVIS_SELECTED)==LVIS_SELECTED)
		{
		//	m_worknoteDlg.m_worknoteInfo->m_notenum=m_listctrl.GetItemText(i,0);
		//	m_worknoteDlg.m_notenum=m_listctrl.GetItemText(i,0);
		//	m_worknoteDlg.Name=m_listctrl.GetItemText(i,2);
		//	IsSelected=TRUE;
		    break;
		}
	}
	if(i<m_pList.GetItemCount())
	{

		int temp=m_pList.GetSelectionMark();
		temp++;
		m_pSet->SetAbsolutePosition(((long)temp));
	
		CUSERDoc* pDoc = GetDocument();

		CDialogUser dialog;
		dialog.m_pClassStr=m_pSet->m_usergroup;
		dialog.m_pDepartmentStr=m_pSet->m_userdepartment;
		dialog.m_pDuty=m_pSet->m_userduty;
//	dialog.m_pMark=m_pSet->m_usermark;
		dialog.m_pRadio=m_pSet->m_userrole-1;
		dialog.m_pRadiotemp=dialog.m_pRadio;
		dialog.m_pUserCName=m_pSet->m_usercname;
		dialog.m_pUserEName=m_pSet->m_userename;
		dialog.m_pUserENametemp=dialog.m_pUserEName;
		dialog.m_UserMemo=m_pSet->m_usermemo;
		dialog.m_UserPassword=m_pSet->m_userpassword;
		dialog.m_UserPasswordR=m_pSet->m_userpassword;
		if(dialog.DoModal()==IDOK)
		{
			m_pSet->Edit();
			m_pSet->m_usergroup=dialog.m_pClassStr;
			m_pSet->m_userdepartment=dialog.m_pDepartmentStr;
			m_pSet->m_userduty=dialog.m_pDuty;
//		m_pSet->m_usermark=dialog.m_pMark;
			m_pSet->m_userrole=dialog.m_pRadio+1;
			m_pSet->m_usercname=dialog.m_pUserCName;
			m_pSet->m_userename=dialog.m_pUserEName;
			m_pSet->m_usermemo=dialog.m_UserMemo;
			m_pSet->m_userpassword=dialog.m_UserPassword;
			m_pSet->Update();
			m_pSet->Requery();
			OnInitialUpdate();
		}
//	m_pList.UpdateData();	
	}
	else
	{
		AfxMessageBox("请先选择您想操作的对象");
	}
}

void CUSERView::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
/*	CUSERDoc* pDoc = GetDocument();

	char pstring[56];
	DWORD length=56;
	GetCurrentDirectory(length,pstring);
 
	CFileStatus fileStatus; 
	CString fileLocate=pstring;
	fileLocate=fileLocate+"\\Forest.bmp"; 
	CFile file(fileLocate,CFile::modeRead);

	BITMAPFILEHEADER fileinfo;
	file.Read(&fileinfo,sizeof(fileinfo));
//	m_Off=fileinfo.bfOffBits; 
	UINT offset = fileinfo.bfOffBits; 
//////////////////////////////////////////////////////////
	UINT length2 = file.GetLength() - sizeof(BITMAPFILEHEADER);
	HANDLE m_DibMem=GlobalAlloc(GMEM_MOVEABLE|GMEM_DISCARDABLE,length2);
	if (m_DibMem == NULL)
	{
		//AfxMessageBox("Error in m_DibMem");
		return;
	}
		char strFile[56];
	GetCurrentDirectory(56,strFile);
	CString str=strFile;
	str+="\\BKbmp.bmp";
//	CDC *dc=this->GetDC();
    m_bmp->LoadFromFile(str);
	m_bmp->Draw(*pDC);
	int xDst,yDst,dxDst,dyDst,xSrc,ySrc,dxSrc,dySrc;
	LPBITMAPINFOHEADER lpbi;
	LPVOID lpDibMem;
	LPVOID lpbits=NULL;

	// get the Windows width & height
	RECT rect;
	GetClientRect(&rect);
	xDst = yDst = 0;
	dxDst = rect.right - rect.left;
	dyDst = rect.bottom - rect.top;

	// Get Dib info
	xSrc = ySrc =0;
	lpDibMem = GlobalLock(m_DibMem);
	lpbi = (LPBITMAPINFOHEADER)lpDibMem;
	
	dxSrc = lpbi->biWidth; 
    dySrc = lpbi->biHeight; 
    lpbits = (LPSTR)lpDibMem + offset -sizeof(BITMAPFILEHEADER);

	// Draw Dib
	HDC hdc = NULL;
	hdc = dc.m_hDC;

	UINT wFlags;
	//wFlags = DDF_DONTDRAW;
	wFlags = DDF_NOTKEYFRAME;

	HDRAWDIB hdd = DrawDibOpen();
	if (hdd != NULL) 
	{
		//DrawDibBegin(hdd,hdc,dxDst,dyDst,lpbi,dxSrc,dySrc,DDF_JUSTDRAWIT);
		BOOL Suc = TRUE;
		Suc = DrawDibDraw(hdd,hdc,xDst,yDst,dxDst,dyDst,lpbi,lpbits,
					xSrc,ySrc,dxSrc,dySrc,wFlags);
		if(Suc == FALSE) AfxMessageBox("DrawDib Failed");
		
		DrawDibClose(hdd);
	}
	else
		AfxMessageBox("Error in DrawDibOpen");

	
	GlobalUnlock(m_DibMem);*/
	CString str;
	str="BKbmp.bmp";
	RECT rect;
	CRect rt;
	GetClientRect(&rect);
	rt.top=rect.top;
	rt.bottom=rect.bottom;
	rt.left=rect.left;
	rt.right=rect.right;
//	CDC *dc=this->GetDC();
    m_bmp->LoadFromFile(str);
	m_bmp->Draw(dc,&rt,NULL);
	// Do not call CRecordView::OnPaint() for painting messages
}

void CUSERView::OnDblclkUserlist(NMHDR* pNMHDR, LRESULT* pResult) 
{
	// TODO: Add your control notification handler code here
	OnMenuedituser();
	*pResult = 0;
}

void CUSERView::OnMenulock() 
{
	// TODO: Add your command handler code here
	CLockDialog dialog;
	dialog.password=m_pPassword;
	while(dialog.DoModal()==IDCANCEL)
	{
	//	dialog.DoModal();
	}

}

void CUSERView::OnMenurepassword() 
{
	// TODO: Add your command handler code here
	CEditDialog2 dialog;
	dialog.DoModal();
}

void CUSERView::OnDraw(CDC* pDC) 
{
	// TODO: Add your specialized code here and/or call the base class

	
}

⌨️ 快捷键说明

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