studentdeletecourse.cpp
上传用户:yhxbjx
上传日期:2018-11-07
资源大小:7142k
文件大小:2k
源码类别:

数据库系统

开发平台:

Visual C++

  1. // studentdeletecourse.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "课程设计.h"
  5. #include "studentdeletecourse.h"
  6. #include "tch.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. /////////////////////////////////////////////////////////////////////////////
  13. // studentdeletecourse dialog
  14. studentdeletecourse::studentdeletecourse(CWnd* pParent /*=NULL*/)
  15. : CDialog(studentdeletecourse::IDD, pParent)
  16. {
  17. //{{AFX_DATA_INIT(studentdeletecourse)
  18. deletecourse = _T("");
  19. deletestudent = _T("");
  20. //}}AFX_DATA_INIT
  21. }
  22. void studentdeletecourse::DoDataExchange(CDataExchange* pDX)
  23. {
  24. CDialog::DoDataExchange(pDX);
  25. //{{AFX_DATA_MAP(studentdeletecourse)
  26. DDX_Text(pDX, IDC_EDIT1, deletecourse);
  27. DDX_Text(pDX, IDC_EDIT2, deletestudent);
  28. //}}AFX_DATA_MAP
  29. }
  30. BEGIN_MESSAGE_MAP(studentdeletecourse, CDialog)
  31. //{{AFX_MSG_MAP(studentdeletecourse)
  32. //}}AFX_MSG_MAP
  33. END_MESSAGE_MAP()
  34. /////////////////////////////////////////////////////////////////////////////
  35. // studentdeletecourse message handlers
  36. int studentdeletecourse::DoModal() 
  37. {
  38. // TODO: Add your specialized code here and/or call the base class
  39. return CDialog::DoModal();
  40. }
  41. void studentdeletecourse::OnOK() 
  42. {
  43. // TODO: Add extra validation here
  44. UpdateData();
  45.     int flag=0;
  46. tch a;
  47. a.Open();
  48. while(!a.IsEOF())
  49. {if(deletestudent==a.m_student)
  50. {if(deletecourse==a.m_xueke1)
  51. {   a.Edit();
  52.     a.m_xueke1="";
  53. a.Update();
  54.     flag=1;
  55. break;}
  56. if(deletecourse==a.m_xueke2)
  57. {a.Edit();
  58.     a.m_xueke2="";
  59. a.Update();
  60. flag=1;
  61. break;
  62.  
  63. }
  64. if(deletecourse==a.m_xueke3)
  65. {a.Edit();
  66.     a.m_xueke3="";
  67. a.Update();
  68.  flag=1;
  69. break;
  70. }
  71. if(deletecourse==a.m_xueke4)
  72. {a.Edit();
  73.     a.m_xueke4="";
  74. a.Update();
  75. flag=1;
  76. break;
  77.  
  78. }
  79. if(deletecourse==a.m_xueke5)
  80. {a.Edit();
  81.     a.m_xueke5="";
  82. a.Update();
  83. flag=1;
  84. break;
  85.  
  86. }
  87. if(deletecourse==a.m_xueke6)
  88. {a.Edit();
  89.     a.m_xueke6="";
  90. a.Update();
  91. flag=1;
  92. break;
  93.  
  94. }
  95. if(deletecourse==a.m_xueke7)
  96. {a.Edit();
  97.     a.m_xueke7="";
  98. a.Update();
  99. flag=1;
  100. break;
  101.  
  102. }
  103. }
  104.   a.MoveNext();
  105. }
  106. if(flag==0)
  107. {MessageBox("该用户或课程不存在!!!","提示",64);}
  108. if(flag==1)
  109. {   /*a.Delete();
  110.     a.Requery();
  111.     UpdateData(false);*/
  112. MessageBox("已删除成功!","提示",64);
  113.     this->OnCancel();
  114. }
  115. }