Пример #1
0
void CPhonesListBox::NewEntry()
{
    CEditDialog dlg;
    if (dlg.DoModal () == IDOK) {
        CString strItem = dlg.m_strName + _T ("\t") + dlg.m_strPhone;
        AddString (strItem);
    }
    SetFocus ();
}
Пример #2
0
void CPhonesListBox::OnEditItem() 
{
    CEditDialog dlg;

    CString strItem;
    int nIndex = GetCurSel ();
    GetText (nIndex, strItem);
    int nPos = strItem.Find (_T ('\t'));

    dlg.m_strName = strItem.Left (nPos);
    dlg.m_strPhone = strItem.Right (strItem.GetLength () - nPos - 1);

    if (dlg.DoModal () == IDOK) {
        strItem = dlg.m_strName + _T ("\t") + dlg.m_strPhone;
        DeleteString (nIndex);
        AddString (strItem);
    }
    SetFocus ();
}
Пример #3
0
void CBaDialog::OnEdit()  //修改学生记录,关键字为--> "学号"
{
	// TODO: Add your control notification handler code here
	CEditDialog dlg;
	if(dlg.DoModal()==IDOK)
	{
    if(strcmp(dlg.m_strPass,"198509")!=0)
			AfxMessageBox("你没有权限更改记录!请重输入密码:");
    else
		{
			this->Select();
	    m_Set.m_strFilter.Format("[学号]=%d",dlg.m_nXuehao);
			m_Set.Requery();
			
			if(m_Set.IsEOF())
				AfxMessageBox("没有此记录");
			else
			{   
				for(int i=0;i<5;i++)
				{
					double 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();
	 }
 }
}