userviewdialog.cpp
上传用户:yhxbjx
上传日期:2018-11-07
资源大小:7142k
文件大小:7k
- // userviewdialog.cpp : implementation file
- //
- #include "stdafx.h"
- #include "课程设计.h"
- #include "userviewdialog.h"
- #include "managerlogoldialog.h"
- #include "addstudentinfor.h"
- #include "refindresource.h"
- #include "deletest.h"
- #include "st.h"
- #include "tch.h"
- #include "sct.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // userviewdialog dialog
- userviewdialog::userviewdialog(CWnd* pParent /*=NULL*/)
- : CDialog(userviewdialog::IDD, pParent)
- {
- //{{AFX_DATA_INIT(userviewdialog)
- studentsecret = _T("");
- //}}AFX_DATA_INIT
- }
- void userviewdialog::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(userviewdialog)
- DDX_Control(pDX, IDC_LIST2, m_listctrl2);
- DDX_Control(pDX, IDC_LIST1, m_listctrl1);
- DDX_Text(pDX, IDC_EDIT1, studentsecret);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(userviewdialog, CDialog)
- //{{AFX_MSG_MAP(userviewdialog)
- ON_COMMAND(ID_fix, Onfix)
- ON_COMMAND(ID_exit, Onexit)
- ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
- ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
- ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
- ON_BN_CLICKED(IDC_BUTTON4, OnButton4)
- ON_COMMAND(ID_resourcefind, Onresourcefind)
- ON_COMMAND(ID_clear, Onclear)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // userviewdialog message handlers
- void userviewdialog::Onfix()
- {
- // TODO: Add your command handler code here
- managerlogoldialog a;
- a.DoModal();
- }
- void userviewdialog::Onexit()
- {
- // TODO: Add your command handler code here
-
- this->OnCancel();
- x=0;
- }
- BOOL userviewdialog::OnInitDialog()
- {
- CDialog::OnInitDialog();
- LVS_ICON;// 为每个item显示大图标
- LVS_SMALLICON;// 为每个item显示小图标
- LVS_LIST;// 显示一列带有小图标的item
- LVS_REPORT;// 显示item详细资料
- LONG lStyle;
- lStyle = GetWindowLong(m_listctrl1.m_hWnd, GWL_STYLE);//获取当前窗口style
- lStyle = GetWindowLong(m_listctrl2.m_hWnd, GWL_STYLE);
- lStyle &= ~LVS_TYPEMASK; //清除显示方式位
- lStyle |= LVS_REPORT; //设置style
- SetWindowLong(m_listctrl1.m_hWnd, GWL_STYLE, lStyle);//设置style
- SetWindowLong(m_listctrl2.m_hWnd, GWL_STYLE, lStyle);
- DWORD dwStyle = m_listctrl1.GetExtendedStyle();
-
- dwStyle |= LVS_EX_FULLROWSELECT;//选中某行使整行高亮(只适用与report风格的listctrl)
- dwStyle |= LVS_EX_GRIDLINES;//网格线(只适用与report风格的listctrl)
- dwStyle |= LVS_EX_CHECKBOXES;//item前生成checkbox控件
- m_listctrl1.SetExtendedStyle(dwStyle);
- DWORD dwStyle2 = m_listctrl2.GetExtendedStyle();
- dwStyle2 |= LVS_EX_FULLROWSELECT;//选中某行使整行高亮(只适用与report风格的listctrl)
- dwStyle2 |= LVS_EX_GRIDLINES;//网格线(只适用与report风格的listctrl)
- dwStyle2 |= LVS_EX_CHECKBOXES;//
- m_listctrl2.SetExtendedStyle(dwStyle2);
- // TODO: Add extra initialization here
- m_listctrl1.InsertColumn( 0, "课程", LVCFMT_LEFT, 130 );//插入列
- m_listctrl1.InsertColumn( 1, "学时", LVCFMT_LEFT, 120 );
- m_listctrl1.InsertColumn( 2, "学分", LVCFMT_LEFT, 120 );
- m_listctrl1.InsertColumn( 3, "地点", LVCFMT_LEFT, 120 );
- m_listctrl1.InsertColumn( 4, "类别", LVCFMT_LEFT, 120 );
- m_listctrl1.InsertColumn( 5, "教师", LVCFMT_LEFT, 120 );
- m_listctrl1.InsertColumn( 6, "水平", LVCFMT_LEFT, 120 );
- //int nRow = m_listctrl1.InsertItem(0, "课程");//插入行
- m_listctrl2.InsertColumn( 0, "学号", LVCFMT_LEFT, 120 );
- m_listctrl2.InsertColumn( 1, "姓名", LVCFMT_LEFT, 120 );
- m_listctrl2.InsertColumn( 2, "性别", LVCFMT_LEFT, 120 );
- m_listctrl2.InsertColumn( 3, "班级", LVCFMT_LEFT, 120 );
- m_listctrl2.InsertColumn( 4, "课程1", LVCFMT_LEFT, 120);
- m_listctrl2.InsertColumn( 5, "课程2", LVCFMT_LEFT, 120);
- m_listctrl2.InsertColumn( 6, "课程3", LVCFMT_LEFT,120);
- m_listctrl2.InsertColumn( 7, "课程4", LVCFMT_LEFT, 120 );
- m_listctrl2.InsertColumn( 8, "课程5", LVCFMT_LEFT, 120);
- m_listctrl2.InsertColumn( 9, "课程6", LVCFMT_LEFT, 120 );
- m_listctrl2.InsertColumn( 10, "课程7", LVCFMT_LEFT, 120 );
-
- //m_listctrl1.SetItemText(nRow, 1, "jacky");//设置数据
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void userviewdialog::OnButton1()
- {
- // TODO: Add your control notification handler code here
- //static int a=0;
- m_listctrl1.DeleteAllItems();
- st a1;
- a1.Open();
- int i=0;
- a1.MoveFirst();
- //if(a==0||x==0)
- do
- {
-
- m_listctrl1.InsertItem(i,a1.m_course,0);
-
- m_listctrl1.SetItemText(i,1,a1.m_period);
-
- m_listctrl1.SetItemText(i,2,a1.m_xuefen);
-
- m_listctrl1.SetItemText(i,3,a1.m_address);
- m_listctrl1.SetItemText(i,4,a1.m_grade);
- m_listctrl1.SetItemText(i,5,a1.m_teacher);
- m_listctrl1.SetItemText(i,6,a1.m_level);
- i++;
- a1.MoveNext();
-
- } while(!a1.IsEOF());
- //a++;
-
- a1.Close();
- }
- void userviewdialog::OnButton2()
- {
- // TODO: Add your control notification handler code here
- m_listctrl2.DeleteAllItems();
- tch a1;
- a1.Open();
- int i=0;
- a1.MoveFirst();
- //if(a==0||x==0)
-
- do
- {
-
- m_listctrl2.InsertItem(i,a1.m_ID,0);
-
- m_listctrl2.SetItemText(i,1,a1.m_student);
-
- m_listctrl2.SetItemText(i,2,a1.m_sex);
-
- m_listctrl2.SetItemText(i,3,a1.m_class);
- m_listctrl2.SetItemText(i,4,a1.m_xueke1);
- m_listctrl2.SetItemText(i,5,a1.m_xueke2);
- m_listctrl2.SetItemText(i,6,a1.m_xueke3);
- m_listctrl2.SetItemText(i,7,a1.m_xueke4);
- m_listctrl2.SetItemText(i,8,a1.m_xueke5);
- m_listctrl2.SetItemText(i,9,a1.m_xueke6);
- m_listctrl2.SetItemText(i,10,a1.m_xueke7);
- i++;
- a1.MoveNext();
-
- } while(!a1.IsEOF());
- //a++;
-
- a1.Close();
- }
- void userviewdialog::OnButton3()
- {
- // TODO: Add your control notification handler code here
- userviewdialog b;
- sct c;
- UpdateData();
- if(studentsecret=="888")
- {addstudentinfor a;
- a.DoModal();
- }
- else
- MessageBox("请先输入正确密码!!!","警告",16);
- }
- void userviewdialog::OnButton4()
- {
- // TODO: Add your control notification handler code here
- UpdateData();
- if(studentsecret=="888")
- {
- deletest a;
- a.DoModal();
- }
- else
- MessageBox("请先输入正确密码!!!","警告",16);
- }
- void userviewdialog::Onresourcefind()
- {
- // TODO: Add your command handler code here
- refindresource a;
- a.DoModal();
- }
- void userviewdialog::Onclear()
- {
- // TODO: Add your command handler code here
- m_listctrl1.DeleteAllItems();
- m_listctrl2.DeleteAllItems();
- }