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

📄 databaseview.cpp

📁 一个access数据库管理系统
💻 CPP
📖 第 1 页 / 共 3 页
字号:
	if(dlg.DoModal()==IDOK){
			m_pSet->Edit();
        	m_pSet->m_stuid=dlg.m_StuID;
    		m_pSet->m_name=dlg.m_StuName;
    		m_pSet->m_sex=dlg.m_sex;
    		m_pSet->m_profcode=dlg.m_ProfCode;
    		m_pSet->m_address=dlg.m_address;
			m_pSet->Update();
			m_pSet->Requery();
    		UpdateData(FALSE);
			AfxMessageBox("记录修改成功!");
	}
	OnRefresh();
	
}


void CDATABASEView::OnSort() 
{
	CString str;
	if(IsDlgButtonChecked(IDC_SORT_ID))str="stuid";
	else if(IsDlgButtonChecked(IDC_SORT_NAME))str="name";
    else str="profcode";
	
	
	m_pSet->m_strSort=str;
	m_pSet->Requery();
	OnRefresh();

}

void CDATABASEView::OnRefresh() 
{

	m_pSet->MoveFirst();
	while(!m_pSet->IsEOF()){
		m_pSet->MoveNext();
		m_pSet->GetRecordCount();
	}
	m_pSet->MoveFirst();
	m_MSFGrid.SetCols(m_pSet->m_nFields+1);
	m_MSFGrid.SetRows(m_pSet->GetRecordCount()+1);
	m_MSFGrid.SetRow(0);
	m_MSFGrid.SetCol(1);
	m_MSFGrid.SetText("学号");
	m_MSFGrid.SetRow(0);
	m_MSFGrid.SetCol(2);
	m_MSFGrid.SetText("姓名");
	m_MSFGrid.SetRow(0);
	m_MSFGrid.SetCol(3);
	m_MSFGrid.SetText("性别");
	m_MSFGrid.SetRow(0);
	m_MSFGrid.SetCol(4);
	m_MSFGrid.SetText("专业代号");
    m_MSFGrid.SetRow(0);
	m_MSFGrid.SetCol(5);
	m_MSFGrid.SetText("联系方式");
	int iRow=1;
	while(!m_pSet->IsEOF())
	{
		CString str;
		str.Format("记录%d",iRow);
		m_MSFGrid.SetRow(iRow);m_MSFGrid.SetCol(0);
		m_MSFGrid.SetText(str);
		m_MSFGrid.SetRow(iRow);m_MSFGrid.SetCol(1);
		m_MSFGrid.SetText(m_pSet->m_stuid);
		m_MSFGrid.SetRow(iRow);m_MSFGrid.SetCol(2);
		m_MSFGrid.SetText(m_pSet->m_name);
		m_MSFGrid.SetRow(iRow);m_MSFGrid.SetCol(3);
		m_MSFGrid.SetText(m_pSet->m_sex);
		m_MSFGrid.SetRow(iRow);m_MSFGrid.SetCol(4);
		m_MSFGrid.SetText(m_pSet->m_profcode);
		m_MSFGrid.SetRow(iRow);m_MSFGrid.SetCol(5);
		m_MSFGrid.SetText(m_pSet->m_address);

		iRow++;
		m_pSet->MoveNext();
	}
	m_MSFGrid.SetRow(1);
	m_MSFGrid.SetCol(1);
    m_pSet->MoveFirst();
	
}

void CDATABASEView::OnXueji() 
{
	CXueji xuejiSet;
	CCodeSet codeSet;
	CXuejiDlg dlg;
	CAdd add_dlg;
	dlg.m_xuejiid=m_pSet->m_stuid;
	dlg.m_xuejiname=m_pSet->m_name;
	
	codeSet.Open();
	codeSet.m_strFilter.Format("profcode='%s'",m_pSet->m_profcode);
	codeSet.Requery();
    dlg.m_xuejiprof=codeSet.m_profname;
    xuejiSet.Open();
	xuejiSet.m_strFilter.Format("stuid='%s'",m_pSet->m_stuid);
    xuejiSet.Requery();
	if(xuejiSet.IsEOF()){
	    if(add_dlg.DoModal()==IDOK)
			if(dlg.DoModal()==IDOK)
			{
				xuejiSet.AddNew();
				xuejiSet.SetFieldNull(&(xuejiSet.m_stuid),FALSE);
				xuejiSet.m_stuid=m_pSet->m_stuid;
        		xuejiSet.m_year=dlg.m_xuejiyear;
        		xuejiSet.m_reg=dlg.m_xuejireg;
        		xuejiSet.m_native=dlg.m_xuejinative;
        		xuejiSet.m_type=dlg.m_xuejitype;
				xuejiSet.m_birth=dlg.m_xuejibirth;
				xuejiSet.m_class=dlg.m_xuejiclass;
        		xuejiSet.Update();
          		UpdateData(FALSE);
				AfxMessageBox("记录添加成功!");
			}
	}
	else
	{
    	dlg.m_xuejiyear=xuejiSet.m_year;
    	dlg.m_xuejireg=xuejiSet.m_reg;
    	dlg.m_xuejinative=xuejiSet.m_native;
        dlg.m_xuejitype=xuejiSet.m_type;
		dlg.m_xuejibirth=xuejiSet.m_birth;
		dlg.m_xuejiclass=xuejiSet.m_class;
    	UpdateData(FALSE);
    	if(dlg.DoModal()==IDOK)
		{
    		xuejiSet.Edit();
    		xuejiSet.m_year=dlg.m_xuejiyear;
    		xuejiSet.m_reg=dlg.m_xuejireg;
    		xuejiSet.m_native=dlg.m_xuejinative;
    		xuejiSet.m_type=dlg.m_xuejitype;
			xuejiSet.m_birth=dlg.m_xuejibirth;
			xuejiSet.m_class=dlg.m_xuejiclass;
    		xuejiSet.Update();
    		UpdateData(FALSE);
			AfxMessageBox("记录修改成功!");
		}
	}
}

void CDATABASEView::OnXuanxiu() 
{
	CXxDlg dlg;
	CXxSet xxSet;
	CAdd   add_dlg;
	dlg.m_stuid=m_pSet->m_stuid;
	dlg.m_name=m_pSet->m_name;
    xxSet.Open();
	xxSet.m_strFilter.Format("stuid='%s'",m_pSet->m_stuid);
	xxSet.Requery();
	if(xxSet.IsEOF()){
	    if(add_dlg.DoModal()==IDOK)
			if(dlg.DoModal()==IDOK)
			{
				xxSet.AddNew();
				xxSet.SetFieldNull(&(xxSet.m_stuid),FALSE);
				xxSet.m_stuid=m_pSet->m_stuid;
	        	xxSet.m_credit=dlg.m_credit;
		        xxSet.m_lesson1=dlg.m_lesson1;
	        	xxSet.m_lesson2=dlg.m_lesson2;
         		xxSet.m_lesson3=dlg.m_lesson3;
          		xxSet.m_lesson4=dlg.m_lesson4;
        		xxSet.Update();
          		UpdateData(FALSE);
				AfxMessageBox("记录添加成功!");
			}
	}
	
	else
	{

	dlg.m_credit=xxSet.m_credit;
	dlg.m_lesson1=xxSet.m_lesson1;
	dlg.m_lesson2=xxSet.m_lesson2;
	dlg.m_lesson3=xxSet.m_lesson3;
	dlg.m_lesson4=xxSet.m_lesson4;
	UpdateData(FALSE);
	if(dlg.DoModal()==IDOK)
	{
		xxSet.Edit();
		xxSet.m_credit=dlg.m_credit;
		xxSet.m_lesson1=dlg.m_lesson1;
		xxSet.m_lesson2=dlg.m_lesson2;
		xxSet.m_lesson3=dlg.m_lesson3;
		xxSet.m_lesson4=dlg.m_lesson4;
		xxSet.Update();
		UpdateData(FALSE);
		AfxMessageBox("记录修改成功!");
	}
	}
}

void CDATABASEView::OnScore() 
{
     CCjDlg dlg;
	 CAdd   add_dlg;
	 CCjSet cjSet;
	 CKmSet kmSet;
	 CKmSet2 kmSet2;
	 
	 float cr[8];
	 int i=0;
	 for(int j=0;j<=7;j++)cr[j]=0;
	 
     dlg.m_name1.Format("姓名: %s          学号: %s",m_pSet->m_name,m_pSet->m_stuid);
	 dlg.m_ave1="加权平均分";
	 kmSet2.Open();
	 kmSet2.m_strFilter.Format("profcode='%s'",m_pSet->m_profcode);
	 kmSet2.Requery();
	 if(kmSet2.m_subject1!=""){
		 dlg.m_score11.Format("%s\t\t(学分:%3.1f)",kmSet2.m_subject1,kmSet2.m_credit1);
         cr[i++]=kmSet2.m_credit1;
	 }
	 if(kmSet2.m_subject2!=""){
		 dlg.m_score21.Format("%s\t\t(学分:%3.1f)",kmSet2.m_subject2,kmSet2.m_credit2);
         cr[i++]=kmSet2.m_credit2;
	 }
	 if(kmSet2.m_subject3!=""){
		 dlg.m_score31.Format("%s\t\t(学分:%3.1f)",kmSet2.m_subject3,kmSet2.m_credit3);
         cr[i++]=kmSet2.m_credit3;
	 }
	 if(kmSet2.m_subject4!=""){
		 dlg.m_score41.Format("%s\t\t(学分:%3.1f)",kmSet2.m_subject4,kmSet2.m_credit4);
         cr[i++]=kmSet2.m_credit4;
	 }
	 if(kmSet2.m_subject5!=""){
		 dlg.m_score51.Format("%s\t\t(学分:%3.1f)",kmSet2.m_subject5,kmSet2.m_credit5);
         cr[i++]=kmSet2.m_credit5;
	 }
	 if(kmSet2.m_subject6!=""){
		 dlg.m_score61.Format("%s\t\t(学分:%3.1f)",kmSet2.m_subject6,kmSet2.m_credit6);
         cr[i++]=kmSet2.m_credit6;
	 }
	 if(kmSet2.m_subject7!=""){
		 dlg.m_score71.Format("%s\t\t(学分:%3.1f)",kmSet2.m_subject7,kmSet2.m_credit7);
         cr[i++]=kmSet2.m_credit7;
	 }
	 if(kmSet2.m_subject8!=""){
		 dlg.m_score81.Format("%s\t\t(学分:%3.1f)",kmSet2.m_subject8,kmSet2.m_credit8);
         cr[i++]=kmSet2.m_credit8;
	 }
	 	 
	 cjSet.Open();
	 cjSet.m_strFilter.Format("stuid='%s'",m_pSet->m_stuid);
	 cjSet.Requery();
	 if(cjSet.IsEOF()){
	    if(add_dlg.DoModal()==IDOK)
			if(dlg.DoModal()==IDOK)
			{
				cjSet.AddNew();
				cjSet.SetFieldNull(&(cjSet.m_stuid),FALSE);
				cjSet.m_stuid=m_pSet->m_stuid;
		        cjSet.m_score1=dlg.m_score12;
	        	cjSet.m_score2=dlg.m_score22;
         		cjSet.m_score3=dlg.m_score32;
          		cjSet.m_score4=dlg.m_score42;
				cjSet.m_score5=dlg.m_score52;
				cjSet.m_score6=dlg.m_score62;
				cjSet.m_score7=dlg.m_score72;
				cjSet.m_score8=dlg.m_score82;
				cjSet.m_ave=((float)cjSet.m_score1*cr[0]+(float)cjSet.m_score2*cr[1]+(float)cjSet.m_score3*cr[2]+(float)cjSet.m_score4*cr[3]+(float)cjSet.m_score5*cr[4]+(float)cjSet.m_score6*cr[5]+(float)cjSet.m_score7*cr[6]+(float)cjSet.m_score8*cr[7])/(cr[1]+cr[2]+cr[3]+cr[0]+cr[4]+cr[5]+cr[6]+cr[7]);
        		cjSet.Update();
          		UpdateData(FALSE);
				AfxMessageBox("记录添加成功!");
			}
	}
	
	else
	{

	if(kmSet2.m_subject1!="")dlg.m_score12=cjSet.m_score1;
	else dlg.m_score12=0;
	if(kmSet2.m_subject2!="")dlg.m_score22=cjSet.m_score2;
	else dlg.m_score22=0;
	if(kmSet2.m_subject3!="")dlg.m_score32=cjSet.m_score3;
    else dlg.m_score32=0;
	if(kmSet2.m_subject4!="")dlg.m_score42=cjSet.m_score4;
	else dlg.m_score42=0;
	if(kmSet2.m_subject5!="")dlg.m_score52=cjSet.m_score5;
	else dlg.m_score52=0;
	if(kmSet2.m_subject6!="")dlg.m_score62=cjSet.m_score6;
	else dlg.m_score62=0;
	if(kmSet2.m_subject7!="")dlg.m_score72=cjSet.m_score7;
	else dlg.m_score72=0;
	if(kmSet2.m_subject8!="")dlg.m_score82=cjSet.m_score7;
	else dlg.m_score82=0;
	dlg.m_ave2=cjSet.m_ave;
	UpdateData(FALSE);
	if(dlg.DoModal()==IDOK)
	{
		cjSet.Edit();
		cjSet.m_score1=dlg.m_score12;
		cjSet.m_score2=dlg.m_score22;
		cjSet.m_score3=dlg.m_score32;
		cjSet.m_score4=dlg.m_score42;
		cjSet.m_score5=dlg.m_score52;
		cjSet.m_score6=dlg.m_score62;
		cjSet.m_score7=dlg.m_score72;
		cjSet.m_score8=dlg.m_score82;
		cjSet.m_ave=((float)cjSet.m_score1*cr[0]+(float)cjSet.m_score2*cr[1]+(float)cjSet.m_score3*cr[2]+(float)cjSet.m_score4*cr[3]+(float)cjSet.m_score5*cr[4]+(float)cjSet.m_score6*cr[5]+(float)cjSet.m_score7*cr[6]+(float)cjSet.m_score8*cr[7])/(cr[1]+cr[2]+cr[3]+cr[0]+cr[4]+cr[5]+cr[6]+cr[7]);
		cjSet.Update();
		UpdateData(FALSE);
		AfxMessageBox("记录修改成功!");

	}
	}

	 /*dlg.m_name1.Format("姓名: %s          学号: %s",m_pSet->m_name,m_pSet->m_stuid);
	 dlg.m_ave1="加权平均分";
	 kmSet.Open();
	 kmSet.m_strFilter.Format("profcode='%s'",m_pSet->m_profcode);
	 kmSet.Requery();
	 dlg.m_score11.Format("%s\t\t(学分:%3.1f)",kmSet.m_subject,kmSet.m_credit);
     cr[i++]=kmSet.m_credit;
	 kmSet.MoveNext();
	 
	 dlg.m_score21.Format("%s\t\t(学分:%3.1f)",kmSet.m_subject,kmSet.m_credit);
	 cr[i++]=kmSet.m_credit;
	 kmSet.MoveNext();
	 
	 dlg.m_score31.Format("%s\t\t(学分:%3.1f)",kmSet.m_subject,kmSet.m_credit);
	 cr[i++]=kmSet.m_credit;
	 kmSet.MoveNext();
	 
	 dlg.m_score41.Format("%s\t\t(学分:%3.1f)",kmSet.m_subject,kmSet.m_credit);
	 cr[i++]=kmSet.m_credit;
	 
	 cjSet.Open();
	 cjSet.m_strFilter.Format("stuid='%s'",m_pSet->m_stuid);
	 cjSet.Requery();
	 if(cjSet.IsEOF()){
	    if(add_dlg.DoModal()==IDOK)
			if(dlg.DoModal()==IDOK)
			{
				cjSet.AddNew();
				cjSet.SetFieldNull(&(cjSet.m_stuid),FALSE);
				cjSet.m_stuid=m_pSet->m_stuid;
		        cjSet.m_score1=dlg.m_score12;
	        	cjSet.m_score2=dlg.m_score22;
         		cjSet.m_score3=dlg.m_score32;
          		cjSet.m_score4=dlg.m_score42;
				cjSet.m_ave=((float)cjSet.m_score1*cr[0]+(float)cjSet.m_score2*cr[1]+(float)cjSet.m_score3*cr[2]+(float)cjSet.m_score4*cr[3])/(cr[1]+cr[2]+cr[3]+cr[0]);
        		cjSet.Update();
          		UpdateData(FALSE);
				AfxMessageBox("记录添加成功!");
			}
	}
	
	else
	{

	dlg.m_score12=cjSet.m_score1;
	dlg.m_score22=cjSet.m_score2;
	dlg.m_score32=cjSet.m_score3;
	dlg.m_score42=cjSet.m_score4;
	dlg.m_ave2=cjSet.m_ave;
	UpdateData(FALSE);
	if(dlg.DoModal()==IDOK)
	{
		cjSet.Edit();
		cjSet.m_score1=dlg.m_score12;
		cjSet.m_score2=dlg.m_score22;
		cjSet.m_score3=dlg.m_score32;
		cjSet.m_score4=dlg.m_score42;
		cjSet.m_ave=((float)cjSet.m_score1*cr[0]+(float)cjSet.m_score2*cr[1]+(float)cjSet.m_score3*cr[2]+(float)cjSet.m_score4*cr[3])/(cr[1]+cr[2]+cr[3]+cr[0]);
		cjSet.Update();
		UpdateData(FALSE);
		AfxMessageBox("记录修改成功!");
	}
	}*/
}

⌨️ 快捷键说明

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