?? badialog.cpp
字號(hào):
m_Set.m_column9=(float)(m_Set.m_column8/5);
this->Equal();
m_Set.Update();//Update()一定放在Equal()后
m_Set.MoveFirst();
if(m_Set.m_column1==0)
{
m_Set.Delete();
m_Set.Requery();
}
m_Set.Requery();
this->Xuan();
}
}
void CBaDialog::OnDelect()
{
// TODO: Add your control notification handler code here
CDelectDialog dlg;
Selec=FALSE;
if(dlg.DoModal()==IDOK)
{
if(dlg.m_nPass!=1234)
AfxMessageBox("密碼不正確!你沒(méi)有權(quán)限刪除記錄");
else
{
this->Select();
m_Set.MoveFirst();
BOOL sel=FALSE;
do
{
if(m_Set.m_column1!=dlg.m_nxue)
m_Set.MoveNext();
else
{
m_nRecordCount-=1;
sel=TRUE;
m_bSet.MoveFirst();
this->Equal();
m_Set.Delete();
m_Set.Requery();
break;
}
}while(!m_Set.IsEOF());
if(sel==FALSE)
{
AfxMessageBox("沒(méi)有此記錄");
return;
}
else
this->Xuan();
}
}
}
void CBaDialog::OnFind()
{
// TODO: Add your control notification handler code here
CFinDialog dlg;
if( dlg.DoModal()==IDOK)
{
this->Select();
m_bSet.Close();
if(dlg.m_Getstring2==">=")
m_Set.m_strFilter.Format("[%s]>=%.2f",dlg.m_Getstring1,dlg.m_find);
if(dlg.m_Getstring2=="=")
m_Set.m_strFilter.Format("[%s]=%.2f",dlg.m_Getstring1,dlg.m_find);
if(dlg.m_Getstring2=="<=")
m_Set.m_strFilter.Format("[%s]<=%.2f",dlg.m_Getstring1,dlg.m_find);
m_ListCtrlx.DeleteAllItems();
m_Set.Requery();
if(m_Set.IsEOF())
{
AfxMessageBox("沒(méi)有符合條件的記錄");
m_Set.Close();
return ;
}
else
this->Show();
}
}
void CBaDialog::OnAll()
{
// TODO: Add your control notification handler code here
this->Select();
m_bSet.Close();
m_Set.m_strFilter.Empty();
m_Set.Requery();
m_ListCtrlx.DeleteAllItems();
this->Show();
}
void CBaDialog::OnEdit()
{
// TODO: Add your control notification handler code here
CEditDialog dlg;
if(dlg.DoModal()==IDOK)
{
if(strcmp(dlg.m_pass,"1234")!=0)
AfxMessageBox("你沒(méi)有權(quán)限更改記錄!請(qǐng)重輸入密碼:");
else
{
this->Select();
m_Set.m_strFilter.Format("[學(xué)號(hào)]=%d",dlg.m_xue);
m_Set.Requery();
if(m_Set.IsEOF())
AfxMessageBox("沒(méi)有此記錄");
else
{
for(int i=0;i<5;i++)
{
float p=0,q=0;
if(i==0)
{
p=dlg.m_fmaths;
q=m_Set.m_column3;
}
if(i==1)
{
p=dlg.m_fphysical;
q=m_Set.m_column4;
}
if(i==2)
{
p=dlg.m_fchemistry;
q=m_Set.m_column5;
}
if(i==3)
{
p=dlg.m_fenglish;
q=m_Set.m_column6;
}
if(i==4)
{
p=dlg.m_fpolitic;
q=m_Set.m_column7;
}
m_bSet.Edit();
m_bSet.m_column2=m_bSet.m_column2+p-q;
m_bSet.m_column3=m_bSet.m_column2/m_nRecordCount;
if(p>=60 && q<60)
m_bSet.m_column4+=1;
if(p<60 && q>=60)
m_bSet.m_column4-=1;
if(p>=80 && q<80)
m_bSet.m_column5+=1;
if(p<80 && q>=80)
m_bSet.m_column5-=1;
m_bSet.Update();
if(!m_bSet.IsEOF())
m_bSet.MoveNext();
else
break;
}
m_Set.Edit();
m_Set.m_column2=dlg.m_strName;
m_Set.m_column3=dlg.m_fmaths;
m_Set.m_column4=dlg.m_fphysical;
m_Set.m_column5=dlg.m_fchemistry;
m_Set.m_column6=dlg.m_fenglish;
m_Set.m_column7=dlg.m_fpolitic;
m_Set.m_column8=dlg.m_fmaths+dlg.m_fphysical+dlg.m_fchemistry+dlg.m_fenglish+dlg.m_fpolitic;
m_Set.m_column9=(float)(m_Set.m_column8/5);
m_Set.Update();
}
m_Set.m_strFilter.Empty();
m_bSet.Close();
m_Set.Close();
m_ListCtrlx.DeleteAllItems();
m_ListCtrlb.DeleteAllItems();
this->Select();
this->Show();
this->display();
}
}
}
void CBaDialog::Sort(BOOL isAsc,int secol)
{
if(m_Set.IsOpen())
m_Set.Close();
this->Select();
m_bSet.Close();
CODBCFieldInfo fieldInfo;
m_Set.GetODBCFieldInfo(secol,fieldInfo);
if(isAsc)
{
m_Set.m_strSort=fieldInfo.m_strName+" ASC";
m_bIsAsc=TRUE;
}
else
{
m_Set.m_strSort=fieldInfo.m_strName+" DESC";
m_bIsAsc=FALSE;
}
m_Set.Requery();
}
void CBaDialog::OnColumnclickList3(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
// TODO: Add your control notification handler code here
if(FALSE== m_bS)
{
int k= pNMListView->iSubItem;
Sort(!m_bIsAsc,k);
m_ListCtrlx.DeleteAllItems();
this->Show();
}
*pResult = 0;
}
void CBaDialog::OnCreateTabel(WPARAM wParam)
{
switch (wParam)
{
case 3:
m_Three=_T("三班");
m_cob.AddString("三班");
break;
case 4:
m_Four="四班";
m_cob.AddString("四班");
break;
case 5:
m_Five="五班";
m_cob.AddString("五班");
break;
case 6:
m_Six="六班";
m_cob.AddString("六班");
break;
case 7:
m_Seven="七班";
m_cob.AddString("七班");
break;
case 8:
m_Eight="八班";
m_cob.AddString("八班");
break;
default:
break;
}
Save();
}
void CBaDialog::Save()
{
// TODO: Add your control notification handler code here
CFile bFile;
try
{bFile.Open( lpszFile,CFile::modeCreate | CFile::modeReadWrite);
}
catch(CFileException* e)
{
CString str;
str.Format("%s",e->m_cause);
AfxMessageBox(str);
}
CArchive art(&bFile,CArchive::store);
art.m_pDocument=(CDocument *)&bFile;//重要
if (art.m_pDocument != NULL)
Serialize(art);
}
void CBaDialog::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{ // storing code
ar<<m_Three<<m_Four<<m_Five<<m_Six<<m_Seven<<m_Eight;
}
else
{ // loading code
ar>>m_Three>>m_Four>>m_Five>>m_Six>>m_Seven>>m_Eight;
}
}
void CBaDialog::OnDelTabel(WPARAM wParam)
{ int nIndex;
switch (wParam)
{
case 3:
m_Three=_T("");
nIndex = 0;
while ((nIndex=m_cob.FindString(nIndex, "三班")) != CB_ERR)
{
m_cob.DeleteString( nIndex );
}
break;
case 4:
m_Four="";
nIndex = 0;
while ((nIndex=m_cob.FindString(nIndex, "四班")) != CB_ERR)
{
m_cob.DeleteString( nIndex );
}
break;
case 5:
m_Five="";
nIndex = 0;
while ((nIndex=m_cob.FindString(nIndex, "五班"))!= CB_ERR)
{
m_cob.DeleteString( nIndex );
}
break;
case 6:
m_Six="";
nIndex = 0;
while ((nIndex=m_cob.FindString(nIndex,"六班" )) != CB_ERR)
{
m_cob.DeleteString( nIndex );
}
break;
case 7:
m_Seven="";
nIndex = 0;
while ((nIndex=m_cob.FindString(nIndex,"七班" )) != CB_ERR)
{
m_cob.DeleteString( nIndex );
}
break;
case 8:
m_Eight="";
nIndex = 0;
while ((nIndex=m_cob.FindString(nIndex,"八班" )) != CB_ERR)
{
m_cob.DeleteString( nIndex );
}
break;
default:
break;
}
Save();
}
void CBaDialog::OnSelchangeCombo1()
{
// TODO: Add your control notification handler code here
}
void CBaDialog::OnExport()
{
// TODO: Add your control notification handler code here
CFile aFile;
CFileFind fFind;
BOOL bSuccess;
CString str;
str.Format("\\%s.txt",m_Getstring);
CString lFile= sPath+str;
bSuccess=fFind.FindFile(lFile);
if(!bSuccess)
aFile.Open(lFile,CFile::modeCreate);
else
{
aFile.Open(lFile,CFile::modeReadWrite);
CArchive arr(&aFile,CArchive::store);
this->Select();
m_bSet.Close();
int i=0;
if(m_Set.m_column1==0)
{
m_Set.Close();
return ;
}
m_Set.MoveFirst();
do
{
CString str1,str2,str3,str4,str5,str6,str7,str8,str9;
str1.Format("%d",m_Set.m_column1);
str2=m_Set.m_column2;
str3.Format("%.1f",m_Set.m_column3);
str4.Format("%.1f",m_Set.m_column4);
str5.Format("%.1f",m_Set.m_column5);
str6.Format("%.1f",m_Set.m_column6);
str7.Format("%.1f",m_Set.m_column7);
str8.Format("%.1f",m_Set.m_column8);
str9.Format("%.2f",m_Set.m_column9);
arr<<str1<<m_Set.m_column2<<str3<<str4<<str5<<str6<<str7<<str8<<str9;
i++;
m_Set.MoveNext();
} while(!m_Set.IsEOF());
m_Set.Close();
}
aFile.Close();
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -