📄 systemview.cpp
字号:
void CSystemView::OnChongqi()
{
int temph;
int tempm;
int temps;
temph=tempm=temps=0;
utime utime;
utime.Open();
utime.MoveLast();
CTime Time = CTime::GetCurrentTime();
hour1=Time.GetHour();
minute1=Time.GetMinute();
tempm=abs(minute1-minute);
if(minute1>minute)
temph=(hour1-hour)*60+tempm;
else
temph=(hour1-hour)*60-tempm;
utime.Edit();
utime.m_ztime=Time;
utime.m_total=temph;
utime.Update();
utime.Requery();
utime.Close();
//隐藏图标
NOTIFYICONDATA nd;//托盘
nd.cbSize = sizeof (NOTIFYICONDATA);
nd.hWnd = m_hWnd;
Shell_NotifyIcon(NIM_DELETE, &nd);//托盘
MessageBox("你确定注销当前用户吗?");
ExitWindowsEx(EWX_LOGOFF,0);
// TODO: Add your control notification handler code here
}
void CSystemView::OnShutdown()
{
int temph;
int tempm;
int temps;
temph=tempm=temps=0;
utime utime;
utime.Open();
utime.MoveLast();
CTime Time = CTime::GetCurrentTime();
hour1=Time.GetHour();
minute1=Time.GetMinute();
tempm=abs(minute1-minute);
if(minute1>minute)
temph=(hour1-hour)*60+tempm;
else
temph=(hour1-hour)*60-tempm;
utime.Edit();
utime.m_ztime=Time;
utime.m_total=temph;
utime.Update();
utime.Requery();
utime.Close();
//隐藏图标
NOTIFYICONDATA nd;//托盘
nd.cbSize = sizeof (NOTIFYICONDATA);
nd.hWnd = m_hWnd;
Shell_NotifyIcon(NIM_DELETE, &nd);//托盘
MessageBox("你确定注销当前用户吗?");
ExitWindowsEx(EWX_LOGOFF,0);
// TODO: Add your control notification handler code here
}
void CSystemView::OnUchangepass()
{
upassword upassword;
upasschange dlg;
CRecordsetStatus status;
upassword.Open();
upassword.MoveFirst();
status.m_lCurrentRecord=0;
if(dlg.DoModal()==IDOK)
{
if(dlg.m_ucnpass==dlg.m_ucnpassd)
{
for( status.m_lCurrentRecord=0; status.m_lCurrentRecord<upassword.GetRecordCount();status.m_lCurrentRecord++)
{
if(dlg.m_ucopass==upassword.m_upassword&&dlg.m_ucsno==upassword.m_usno)
{
upassword.Edit();
upassword.m_upassword=dlg.m_ucnpass;
upassword.Update();
upassword.Requery();
MessageBox("口令修改成功!");
}
else
upassword.MoveNext();
}
if(status.m_lCurrentRecord==upassword.GetRecordCount())
MessageBox("此用户并不存在或你输入的旧口令不正确!");
}
else
MessageBox("你两次输入的口令不一致,请核对后重新输入!");
}
// TODO: Add your control notification handler code here
}
void CSystemView::OnDenglu()
{
upassword upassword;
utime utime;
utime.Open();
upassword.Open();
upassword.MoveFirst();
CRecordsetStatus status;
status.m_lCurrentRecord=0;
flag1=true;
CTime Time = CTime::GetCurrentTime();
hour=minute=second=0;
for( status.m_lCurrentRecord=0; status.m_lCurrentRecord<upassword.GetRecordCount();status.m_lCurrentRecord++)
{
UpdateData();
if(m_dusno==upassword.m_usno&&m_dupass==upassword.m_upassword)
{
if(m_position)
{
m_position=false;
utime.AddNew();
utime.m_usno=m_dusno;
utime.m_uname=upassword.m_uname;
utime.m_dtime=Time;
hour=Time.GetHour();
minute=Time.GetMinute();
second=Time.GetSecond();
utime.Update();
utime.Requery();
}
else
MessageBox("你已经登录啦!");
CMainFrame *pFrame=(CMainFrame *)AfxGetApp()->GetMainWnd();
pFrame->ShowWindow(SW_HIDE);
break;
}
else
upassword.MoveNext();
}
if(status.m_lCurrentRecord==upassword.GetRecordCount())
MessageBox("你输入的用户名或口令不正确,请重新输入。");
upassword.Close();
utime.Close();
// SetTimer(1, 1000, NULL);
// TODO: Add your control notification handler code here
}
void CSystemView::OnTimer(UINT nIDEvent)
{
CTime t = CTime::GetCurrentTime();
CString str;
str.Format("%d年%d月%d日",t.GetYear(),t.GetMonth(),t.GetDay());
str+= t.Format("%H时%M分%S秒");
m_time=str;
UpdateData(false);
// TODO: Add your message handler code here and/or call default
CRecordView::OnTimer(nIDEvent);
}
void CSystemView::OnTimecha()
{
utime utime;
utime.Open();
utime.MoveFirst();
UpdateData();
CString str;
CString str1;
CString str2;
CString temp;
CString temp1;
CString str3;
if(flag1)
{
int iRow=1;
while(!utime.IsEOF())
{
if(m_chasno==utime.m_usno)
{
str3.Format("记录%d",iRow);
m_MSFGird.SetRow(iRow);
m_MSFGird.SetCol(0);
m_MSFGird.SetText(str3);
m_MSFGird.SetRow(iRow);
m_MSFGird.SetCol(1);
m_MSFGird.SetText(utime.m_usno);
m_MSFGird.SetRow(iRow);
m_MSFGird.SetCol(2);
m_MSFGird.SetText(utime.m_uname);
m_MSFGird.SetRow(iRow);
m_MSFGird.SetCol(3);
str.Format("%d/%d/%d",utime.m_dtime.GetYear(),utime.m_dtime.GetMonth(),utime.m_dtime.GetDay());
temp.Format(" %d:%d:%d",utime.m_dtime.GetHour(),utime.m_dtime.GetMinute(),utime.m_dtime.GetSecond());
m_MSFGird.SetText(str+temp);
m_MSFGird.SetRow(iRow);
m_MSFGird.SetCol(4);
str1.Format("%d/%d/%d",utime.m_ztime.GetYear(),utime.m_ztime.GetMonth(),utime.m_ztime.GetDay());
temp1.Format(" %d:%d:%d",utime.m_ztime.GetHour(),utime.m_ztime.GetMinute(),utime.m_ztime.GetSecond());
m_MSFGird.SetText(str1+temp1);
m_MSFGird.SetRow(iRow);
m_MSFGird.SetCol(5);
str2.Format("%d",utime.m_total);
m_MSFGird.SetText(str2);
str="";
str1="";
str2="";
temp="";
temp1="";
str3="";
iRow++;
}
utime.MoveNext();
}
m_MSFGird.SetRow(1);
m_MSFGird.SetCol(1);
SetTimer(1, 1000, NULL);
}
else
MessageBox("请先登录!");
//utime.MoveFirst();
// TODO: Add your control notification handler code here
}
void CSystemView::OnKanall()
{
kanallDlg dlg;
dlg.DoModal();
// TODO: Add your command handler code here
}
void CSystemView::OnKilltime()
{
KillTimer(1);
// TODO: Add your control notification handler code here
}
void CSystemView::OnDeljilu()
{
delsnoDlg dlg;
adpass maindlg;
alteradpaset alter;
utime utime;
utime.Open();
utime.MoveFirst();
bool flag2;
flag2=false;
if(maindlg.DoModal()==IDOK)
{
UpdateData();
if(maindlg.m_adpassnum==m_pSet->m_apassword)
{
if(dlg.DoModal()==IDOK)
{
while(!utime.IsEOF())
{
UpdateData();
if(dlg.m_delusno==utime.m_usno)
{
utime.Delete();
flag2=true;
MessageBox("你已成功删除此学号的一个记录!");
break;
}
else
utime.MoveNext();
if(flag2==true)
{
utime.MoveLast();
break;
}
}
}
}
else
MessageBox("管理员口令不正确,你无权进行此操作!");
// TODO: Add your command handler code here
}
}
/*void CSystemView::OnSysCommand()//UINT nID, LPARAM lParam)
{
//if (nID == SC_MAXIMIZE)///????????????????????
// return;
//if (nID == SC_MINIMIZE)
CMainFrame *pFrame=(CMainFrame *)AfxGetApp()->GetMainWnd();
pFrame->ShowWindow(SW_HIDE);
// else
// CWnd::OnSysCommand(nID, lParam);
}
*/
BOOL CSystemView::OnQueryEndSession()
{
// 在用户退出Windows时自动退出应用程序
CSystemView::OnZhuxiao();
return TRUE;
}
afx_msg void CSystemView::OnNotifyIcon(WPARAM wParam, LPARAM lParam)
{
// 响应在托盘图标上的单击
if ((wParam == IDI_ICON)&&(lParam == WM_LBUTTONDOWN))
//ShowWindow(SW_SHOWNORMAL);
{
CMainFrame *pFrame=(CMainFrame *)AfxGetApp()->GetMainWnd();
pFrame->ShowWindow(SW_SHOW);
}
}
HCURSOR CSystemView::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CSystemView::OnDalltime()
{
dalltimeDlg dlg;
dlg.DoModal();
// TODO: Add your command handler code here
}
void CSystemView::OnDraw(CDC* pDC)
{
CSystemDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
CBitmap bmp;
bmp.LoadBitmap(IDB_BITMAP1);
BITMAP bmpinfo;
bmp.GetBitmap(&bmpinfo);
CDC dc;
dc.CreateCompatibleDC(pDC);
CBitmap *poldbmp;
poldbmp=dc.SelectObject(&bmp);
pDC->BitBlt(3,3,bmpinfo.bmWidth,bmpinfo.bmHeight,&dc,0,0,SRCCOPY);
dc.SelectObject(poldbmp);
/*
CBrush brush(RGB (128,0,128) );
// Select the brush into the device context .
CBrush* pOldBrush=pDC->SelectObject(&brush);
// Get the area that needs to be erased .
CRect rect;
pDC->GetClipBox(&rect);
//Paint the area.
pDC->PatBlt (rect.left , rect.top , rect.Width ( ) , rect.Height( ) , PATCOPY );
//Unselect brush out of device context .
pDC->SelectObject (pOldBrush );
*/
// TODO: Add your specialized code here and/or call the base class
}
void CSystemView::OnUseralltime()
{
useralltimeDlg dlg;
dlg.DoModal();
// TODO: Add your command handler code here
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -