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

📄 moduleview.cpp

📁 这是目前正应用于辽宁省很多县级中学的试题库系统源代码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
	UINT uFlags;
	MyList->GetWindowRect(&cListWindowRect);
	cListOriginPoint = cListWindowRect.TopLeft();
	CPoint cTestPoint(cMousePoint.x - cListOriginPoint.x,cMousePoint.y - cListOriginPoint.y);
	int nItem = MyList->HitTest(cTestPoint,&uFlags);

	char strMsg[50];
	CStatusBar* pStatus=(CStatusBar*) AfxGetApp()->m_pMainWnd->GetDescendantWindow(AFX_IDW_STATUS_BAR);
	CTime time=CTime::GetCurrentTime();
	sprintf(strMsg,"%02d:%02d:%02d",time.GetHour(),time.GetMinute(),time.GetSecond());
	pStatus->SetPaneText(4,strMsg);
	if(nItem==0)
	{
		ClientToScreen(&cTestPoint);
		CMenu* pMenu=new CMenu;
		pMenu->LoadMenu(IDR_MENU1);
		CMenu* pFileMenu=pMenu->GetSubMenu(0);
		pFileMenu->TrackPopupMenu(TPM_LEFTALIGN|TPM_RIGHTBUTTON,cTestPoint.x,cTestPoint.y,this);
		delete pMenu;
		pStatus->SetPaneText(0,"这是试题编辑选项,请移动鼠标于上!");
		return;
	}
	if(nItem==1)
	{
		pStatus->SetPaneText(0,"这是试题查询选项,请左键双击!");
		return;
	}
	if(nItem==2)
	{
		pStatus->SetPaneText(0,"这是试题统计选项,请左键双击!");
		return;
	}
	if(nItem==3)
	{
		pStatus->SetPaneText(0,"这是试卷设置选项,请左键双击!");
		return;
	}
	if(nItem==4)
	{
		pStatus->SetPaneText(0,"这是试卷生成选项,请左键双击!");
		return;
	}
	if(nItem==5)
	{
		pStatus->SetPaneText(0,"这是答案生成选项,请左键双击!");
		return;
	}
	else
	{
		if(pMainFrame->BoolConnent==TRUE)
                pStatus->SetPaneText(0,"已经登录数据库!");
	   
        if(pMainFrame->BoolConnent==FALSE)
	            pStatus->SetPaneText(0,"尚未登录数据库!");
	}

	CView::OnTimer(nIDEvent);
}

BOOL CModuleView::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) //设置光标函数
{
	// TODO: Add your message handler code here and/or call default
    
	if(pWnd->GetDlgCtrlID()==ID_LIST)
	{
    CPoint cMousePoint;// 鼠标位置
	GetCursorPos(&cMousePoint);// 屏幕的鼠标位置,并非窗口的
    POINT  cListOriginPoint;
	CRect  cListWindowRect;
	UINT uFlags;
	MyList->GetWindowRect(&cListWindowRect);
	cListOriginPoint = cListWindowRect.TopLeft();
	CPoint cTestPoint(cMousePoint.x - cListOriginPoint.x,cMousePoint.y - cListOriginPoint.y);
	int nItem = MyList->HitTest(cTestPoint,&uFlags);
    
	if(nItem>=0)
	{
	    HCURSOR cur;//创建光标对象
	    cur=AfxGetApp()->LoadCursor(IDC_CURSOR1);
	    SetCursor(cur);
		
	}
	
	return true;
	}

	return CView::OnSetCursor(pWnd, nHitTest, message);
}

void CModuleView::OnInitialUpdate() 
{
	CView::OnInitialUpdate();
	
	// TODO: Add your specialized code here and/or call the base class
	Show();
	
}

int CModuleView::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CView::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	// TODO: Add your specialized creation code here
	SetTimer(1,100,NULL);
	
	return 0;
}

void CModuleView::OnDestroy() 
{
	CView::OnDestroy();
	
	// TODO: Add your message handler code here
	KillTimer(1);
}

void CModuleView::OnBh() 
{
	// TODO: Add your command handler code here

}

void CModuleView::OnLr() //调用录入对话框
{
	// TODO: Add your command handler code here
	CMainFrame* pMainFrame=(CMainFrame*) AfxGetMainWnd();
	if(pMainFrame->BoolConnent==FALSE)
	{
		AfxMessageBox("请连接数据源!");
		return;
	}
	else
	{
		CLrDialog Lrdlg;
	    Lrdlg.DoModal();
	}
}

void CModuleView::OnXg() //调用修改对话框
{
	// TODO: Add your command handler code here
	CTestPaperApp* pApp=(CTestPaperApp*) AfxGetApp();
	CMainFrame* pMainFrame=(CMainFrame*) AfxGetMainWnd();
	if(pMainFrame->BoolConnent==FALSE || pMainFrame->m_recordset.GetRecordCount()==0)
	{
		AfxMessageBox("请连接数据源或无记录!");
		return;
	}
	int i=pMainFrame->testview->m_ListCtrl.GetHotItem();
	if(i==-1)
	{
		AfxMessageBox("请选择修改项!");
		return;
	}
	else
	{
		CTestPaperApp* pApp=(CTestPaperApp*) AfxGetApp();
		if(pApp->enterdlg.struser!="administrator")
		{
		int keyid=atoi(pMainFrame->testview->m_ListCtrl.GetItemText(i,9));
        pMainFrame->m_recordset.MoveFirst();
	    while(!pMainFrame->m_recordset.IsEOF())
		{
		    int jj=9;
		    CDBVariant XgVa;
		    pMainFrame->m_recordset.GetFieldValue(jj,XgVa);
		    if(keyid==XgVa.m_iVal)
			{
				pMainFrame->m_recordset.GetFieldValue(10,XgVa);
				CString jiaobi;
				jiaobi=XgVa.m_pstring->GetBuffer(1);
				jiaobi.TrimLeft();
				jiaobi.TrimRight();
				if(jiaobi.Compare(pApp->enterdlg.struser)!=0)
				{
					AfxMessageBox("对不起,你是一般用户身份!");
					return;
				}


			   break;
			}
		    pMainFrame->m_recordset.MoveNext();
		}
		}
	    pMainFrame->ming=1;
	    CXgDialog Xgdlg;
	    Xgdlg.DoModal();
	}

}

void CModuleView::OnSc() //CDaoRecordset的删除函数
{
	// TODO: Add your command handler code here
	
    CTestPaperApp* pApp=(CTestPaperApp*) AfxGetApp();
    CMainFrame* pMainFrame=(CMainFrame*) AfxGetMainWnd();
	int i=pMainFrame->testview->m_ListCtrl.GetHotItem();
	CString strSQL;
	if(pMainFrame->BoolConnent==FALSE || pMainFrame->m_recordset.GetRecordCount()==0)
	{
		AfxMessageBox("请连接数据源或无记录!");
		return;
	} 
	if(!pMainFrame->m_recordset.CanUpdate())
         return;
	if(i==-1)
	{
		AfxMessageBox("请选择删除项!");
		return;
	}
	else
	{
		CTestPaperApp* pApp=(CTestPaperApp*) AfxGetApp();
		if(pApp->enterdlg.struser!="administrator")
		{
		int keyid=atoi(pMainFrame->testview->m_ListCtrl.GetItemText(i,9));
        pMainFrame->m_recordset.MoveFirst();
	    while(!pMainFrame->m_recordset.IsEOF())
		{
		    int jj=9;
		    CDBVariant XgVa;
		    pMainFrame->m_recordset.GetFieldValue(jj,XgVa);
		    if(keyid==XgVa.m_iVal)
			{
				pMainFrame->m_recordset.GetFieldValue(10,XgVa);
				CString jiaobi;
				jiaobi=XgVa.m_pstring->GetBuffer(1);
				jiaobi.TrimLeft();
				jiaobi.TrimRight();
				if(jiaobi.Compare(pApp->enterdlg.struser)!=0)
				{
					AfxMessageBox("对不起,你是一般用户身份!");
					return;
				}


			   break;
			}
		    pMainFrame->m_recordset.MoveNext();
		}
		}
	    if(AfxMessageBox("确实需要删除该试题吗?",MB_YESNO)==IDYES)
		{
		CString tempstr;
	    CString tempstr2;
	    CString strSQL;
   	    strSQL.Empty();
	    pMainFrame->m_wndAddress1.GetLBText(pMainFrame->m_wndAddress1.GetCurSel(),tempstr);
	    tempstr.TrimLeft("   ");
        pMainFrame->m_wndAddress2.GetLBText(pMainFrame->m_wndAddress2.GetCurSel(),tempstr2);
	    tempstr2.TrimLeft("   ");
	    int keyid=atoi(pMainFrame->testview->m_ListCtrl.GetItemText(i,9));
	    strSQL.Format("delete from %s%s where 识别号=%d",tempstr,tempstr2,keyid);
		pMainFrame->m_database.ExecuteSQL(strSQL);
		pMainFrame->Refreshdata();
		}
		
		
	}
}

void CModuleView::OnQs() 
{
	// TODO: Add your command handler code here
	 CTestPaperApp* pApp=(CTestPaperApp*) AfxGetApp();
     if(pApp->enterdlg.struser!="administrator")
	 {
		AfxMessageBox("对不起!你是一般用户身份!");
		return;
	 }
     CMainFrame* pMainFrame=(CMainFrame*) AfxGetMainWnd();
     
	 if(pMainFrame->BoolConnent==FALSE || pMainFrame->m_recordset.GetRecordCount()==0)
	 {
		AfxMessageBox("请连接数据源或无记录!");
		return;
	 }
	 if(!pMainFrame->m_recordset.CanUpdate())
        return;
     if(AfxMessageBox("确实需要删除全部试题吗?",MB_YESNO)==IDYES)
		{
	    CString tempstr;
	    CString tempstr2;
	    CString strSQL;
   	    strSQL.Empty();
	    pMainFrame->m_wndAddress1.GetLBText(pMainFrame->m_wndAddress1.GetCurSel(),tempstr);
	    tempstr.TrimLeft("   ");
        pMainFrame->m_wndAddress2.GetLBText(pMainFrame->m_wndAddress2.GetCurSel(),tempstr2);
	    tempstr2.TrimLeft("   ");
	    strSQL.Format("delete from %s%s",tempstr,tempstr2);
		pMainFrame->m_database.ExecuteSQL(strSQL);
		pMainFrame->Refreshdata();
	    }
}

BOOL CModuleView::PreTranslateMessage(MSG* pMsg) 
{
	// TODO: Add your specialized code here and/or call the base class   
	return CView::PreTranslateMessage(pMsg);
}

⌨️ 快捷键说明

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