studentaddcourse.cpp
上传用户:yhxbjx
上传日期:2018-11-07
资源大小:7142k
文件大小:3k
- // studentaddcourse.cpp : implementation file
- //
- #include "stdafx.h"
- #include "课程设计.h"
- #include "studentaddcourse.h"
- #include "tch.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // studentaddcourse dialog
- studentaddcourse::studentaddcourse(CWnd* pParent /*=NULL*/)
- : CDialog(studentaddcourse::IDD, pParent)
- {
- //{{AFX_DATA_INIT(studentaddcourse)
- stnewcourse = _T("");
- student = _T("");
- //}}AFX_DATA_INIT
- }
- void studentaddcourse::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(studentaddcourse)
- DDX_Text(pDX, IDC_EDIT1, stnewcourse);
- DDX_Text(pDX, IDC_EDIT2, student);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(studentaddcourse, CDialog)
- //{{AFX_MSG_MAP(studentaddcourse)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // studentaddcourse message handlers
- int studentaddcourse::DoModal()
- {
- // TODO: Add your specialized code here and/or call the base class
-
- return CDialog::DoModal();
- }
- void studentaddcourse::OnOK()
- {
- // TODO: Add extra validation here
-
- UpdateData();
- int flag=0;
- tch a;
- a.Open();
- while(!a.IsEOF())
- {if(student==a.m_student)
- {if(stnewcourse!=a.m_xueke1&&a.m_xueke1=="")
- { //a.AddNew();
- a.Edit();
- a.m_xueke1=stnewcourse;
- a.Update();
- flag=1;
- break;
- }
- if(stnewcourse!=a.m_xueke2&&a.m_xueke2=="")
- { //a.AddNew();
- a.Edit();
- a.m_xueke2=stnewcourse;
- flag=1;
- a.Update();
- break;
- }
- if(stnewcourse!=a.m_xueke3&&a.m_xueke3=="")
- { //a.AddNew();
- a.Edit();
- a.m_xueke3=stnewcourse;
- a.Update();
- flag=1;
- break;
- }
- if(stnewcourse!=a.m_xueke4&&a.m_xueke4=="")
- { //a.AddNew();
- a.Edit();
- a.m_xueke4=stnewcourse;
- a.Update();
- flag=1;
- break;
- }
- if(stnewcourse!=a.m_xueke5&&a.m_xueke5=="")
- { //a.AddNew();
- a.Edit();
- a.m_xueke5=stnewcourse;
- a.Update();
- flag=1;
- break;
- }
- if(stnewcourse!=a.m_xueke6&&a.m_xueke6=="")
- { //a.AddNew();
- a.Edit();
- a.m_xueke6=stnewcourse;
- a.Update();
- flag=1;
- break;
- }
- if(stnewcourse!=a.m_xueke7&&a.m_xueke7=="")
- { //a.AddNew();
- a.Edit();
- a.m_xueke7=stnewcourse;
- a.Update();
- flag=1;
- break;
- }
- }
- a.MoveNext();
- }
- if(flag==0)
- {MessageBox("该用户或课程存在!!!","提示",64);}
- if(flag==1)
- { /*a.Delete();
- a.Requery();
- UpdateData(false);*/
- MessageBox("已增加成功!","提示",64);
- this->OnCancel();
- }
- }