ChangeInsideInfoDlg.cpp
资源名称:school.rar [点击查看]
上传用户:rs600066
上传日期:2017-10-16
资源大小:4788k
文件大小:5k
源码类别:
数据库系统
开发平台:
Visual C++
- // ChangeInsideInfoDlg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "school.h"
- #include "ChangeInsideInfoDlg.h"
- #include "departmentset.h"
- #include "majorset.h"
- #include "classset.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CChangeInsideInfoDlg dialog
- CChangeInsideInfoDlg::CChangeInsideInfoDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CChangeInsideInfoDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CChangeInsideInfoDlg)
- m_strDepartment = _T("");
- m_strSubject = _T("");
- m_strClass = _T("");
- m_strCode = _T("");
- m_strBrief = _T("");
- m_strName = _T("");
- m_strDate = _T("");
- //}}AFX_DATA_INIT
- }
- void CChangeInsideInfoDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CChangeInsideInfoDlg)
- DDX_Control(pDX, IDC_COMBO3_CLASS, m_ctrClass);
- DDX_Control(pDX, IDC_COMBO2_SUBJECT, m_ctrSubject);
- DDX_Control(pDX, IDC_COMBO1_DEPARTMENT, m_ctrDepartment);
- DDX_CBString(pDX, IDC_COMBO1_DEPARTMENT, m_strDepartment);
- DDX_CBString(pDX, IDC_COMBO2_SUBJECT, m_strSubject);
- DDX_CBString(pDX, IDC_COMBO3_CLASS, m_strClass);
- DDX_Text(pDX, IDC_EDIT1_CODE, m_strCode);
- DDX_Text(pDX, IDC_EDIT2_BRIEF, m_strBrief);
- DDX_Text(pDX, IDC_EDIT4_NAME, m_strName);
- DDX_Text(pDX, IDC_EDIT5_DATE, m_strDate);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CChangeInsideInfoDlg, CDialog)
- //{{AFX_MSG_MAP(CChangeInsideInfoDlg)
- ON_CBN_SELCHANGE(IDC_COMBO1_DEPARTMENT, OnSelchangeCombo1Department)
- ON_CBN_SELCHANGE(IDC_COMBO2_SUBJECT, OnSelchangeCombo2Subject)
- ON_CBN_SETFOCUS(IDC_COMBO2_SUBJECT, OnSetfocusCombo2Subject)
- ON_CBN_SETFOCUS(IDC_COMBO3_CLASS, OnSetfocusCombo3Class)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CChangeInsideInfoDlg message handlers
- BOOL CChangeInsideInfoDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
- CDepartmentSet DeptSet ;
- CString strSQL;
- strSQL="select * from department";
- if(!DeptSet.Open(AFX_DB_USE_DEFAULT_TYPE,strSQL))
- {
- MessageBox("打开数据库失败!","数据库错误",MB_OK);
- }
- while(!DeptSet.IsEOF())
- {
- m_ctrDepartment.AddString(DeptSet.m_name);
- DeptSet.MoveNext();
- }
- DeptSet.Close();
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void CChangeInsideInfoDlg::OnOK()
- {
- // TODO: Add extra validation here
- UpdateData();
- if(m_strDepartment.IsEmpty())
- {
- AfxMessageBox("请输入申请系别!");
- return;
- }
- if(m_strCode.IsEmpty())
- {
- AfxMessageBox("请输入编号!");
- return;
- }
- if(m_strClass.IsEmpty())
- {
- AfxMessageBox("请输入申请班级!");
- return;
- }
- if(m_strSubject.IsEmpty())
- {
- AfxMessageBox("请输入申请专业!");
- return;
- }
- if(m_strName.IsEmpty())
- {
- AfxMessageBox("请输入申请人姓名!");
- return;
- }
- CDialog::OnOK();
- }
- void CChangeInsideInfoDlg::OnSelchangeCombo1Department()
- {
- // TODO: Add your control notification handler code here
- UpdateData();
- //清空ComboBox查询内容//////////////////////
- int nCount=m_ctrSubject.GetCount();
- for(int i=0;i<nCount;i++)
- {
- m_ctrSubject.DeleteString(0);
- }
- nCount=m_ctrClass.GetCount();
- for(i=0;i<nCount;i++)
- {
- m_ctrClass.DeleteString(0);
- }
- }
- void CChangeInsideInfoDlg::OnSelchangeCombo2Subject()
- {
- // TODO: Add your control notification handler code here
- UpdateData();
- //清空ComboBox查询内容//////////////////////
- int nCount=m_ctrClass.GetCount();
- for(int i=0;i<nCount;i++)
- {
- m_ctrClass.DeleteString(0);
- }
- }
- void CChangeInsideInfoDlg::OnSetfocusCombo2Subject()
- {
- // TODO: Add your control notification handler code here
- UpdateData();
- CString strSQL;
- //清空ComboBox查询内容//////////////////////
- int nCount=m_ctrSubject.GetCount();
- for(int i=0;i<nCount;i++)
- {
- m_ctrSubject.DeleteString(0);
- }
- nCount=m_ctrClass.GetCount();
- for(i=0;i<nCount;i++)
- {
- m_ctrClass.DeleteString(0);
- }
- ///////////////////////////////////////////
- CMajorSet recordset ;
- strSQL.Format( "select * from major where department = '%s'",m_strDepartment);
- if(!recordset.Open(AFX_DB_USE_DEFAULT_TYPE,strSQL))
- {
- MessageBox("打开数据库失败!","数据库错误",MB_OK);
- return ;
- }
- while(!recordset.IsEOF())
- {
- m_ctrSubject.AddString(recordset.m_name);
- recordset.MoveNext();
- }
- recordset.Close();
- }
- void CChangeInsideInfoDlg::OnSetfocusCombo3Class()
- {
- // TODO: Add your control notification handler code here
- UpdateData();
- CString strSQL;
- //清空ComboBox查询内容//////////////////////
- int nCount=m_ctrClass.GetCount();
- for(int i=0;i<nCount;i++)
- {
- m_ctrClass.DeleteString(0);
- }
- ///////////////////////////////////////////
- CClassSet recordset ;
- strSQL.Format( "select * from class where department = '%s' and major = '%s'",m_strDepartment,m_strSubject);
- if(!recordset.Open(AFX_DB_USE_DEFAULT_TYPE,strSQL))
- {
- MessageBox("打开数据库失败!","数据库错误",MB_OK);
- return ;
- }
- while(!recordset.IsEOF())
- {
- m_ctrClass.AddString(recordset.m_name);
- recordset.MoveNext();
- }
- recordset.Close();
- }