⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chengjitongjidlg.cpp

📁 学生成绩管理系统质量高而且本站没有的源码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// chengjitongjiDlg.cpp : implementation file
//

#include "stdafx.h"
#include "chengjitongji.h"
#include "chengjitongjiDlg.h"
#include <stdlib.h> 
#include <string.h>
#include "score.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

void ConsScoreNode(CString Nname,CString Nnumber,CString Naverage,
				   CString Nmiddle,CString Nfinal,CString Nresultemp,ScoreNode* newnode);
//ScoreNode* head=NULL; 
Score score;

CFile ChengjiText;
CFile ChengjitongjiText;
int j=0;
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
CString Nresultemp;
class CAboutDlg : public CDialog
{
public:
	CAboutDlg();

// Dialog Data
	//{{AFX_DATA(CAboutDlg)
	enum { IDD = IDD_ABOUTBOX };
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CAboutDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	//{{AFX_MSG(CAboutDlg)
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
	//{{AFX_DATA_INIT(CAboutDlg)
	//}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAboutDlg)
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
	//{{AFX_MSG_MAP(CAboutDlg)
		// No message handlers
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CChengjitongjiDlg dialog

CChengjitongjiDlg::CChengjitongjiDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CChengjitongjiDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CChengjitongjiDlg)
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CChengjitongjiDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CChengjitongjiDlg)
	DDX_Control(pDX, IDC_EDIT10, m_charuxuehao);
	DDX_Control(pDX, IDC_COMBO5, m_tongjiqujian);
	DDX_Control(pDX, IDC_COMBO4, m_xianshileibie);
	DDX_Control(pDX, IDC_EDIT9, m_xiugai);
	DDX_Control(pDX, IDC_COMBO3, m_xiugaileibie);
	DDX_Control(pDX, IDC_COMBO2, m_shanchuleibie);
	DDX_Control(pDX, IDC_EDIT8, m_shanchu);
	DDX_Control(pDX, IDC_COMBO1, m_chaxunleibie);
	DDX_Control(pDX, IDC_EDIT7, m_chaxun);
	DDX_Control(pDX, IDC_LIST1, m_show);
	DDX_Control(pDX, IDC_EDIT6, m_result);
	DDX_Control(pDX, IDC_EDIT5, m_final);
	DDX_Control(pDX, IDC_EDIT4, m_middle);
	DDX_Control(pDX, IDC_EDIT3, m_average);
	DDX_Control(pDX, IDC_EDIT2, m_number);
	DDX_Control(pDX, IDC_EDIT1, m_name);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CChengjitongjiDlg, CDialog)
	//{{AFX_MSG_MAP(CChengjitongjiDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_BN_CLICKED(IDOK, Ontianjia)
	ON_BN_CLICKED(IDC_BUTTON1, Onqueding)
	ON_BN_CLICKED(IDC_BUTTON2, Onxianshiyiyoujilu)
	ON_BN_CLICKED(IDC_BUTTON3, Onchaxun)
	ON_BN_CLICKED(IDC_BUTTON4, Onxianshifuwei)
	ON_BN_CLICKED(IDC_BUTTON5, Onshanchu)
	ON_BN_CLICKED(IDC_BUTTON6, Onxiugaijilu)
	ON_BN_CLICKED(IDC_BUTTON7, Ontongji)
	ON_BN_CLICKED(IDC_BUTTON8, Oncharuxinjilu)
	ON_BN_CLICKED(IDC_BUTTON9, OnButtondaoruwenjian)
	ON_BN_CLICKED(IDC_BUTTON10, Onwenjiandaochu)
	ON_BN_CLICKED(IDCANCEL, Onquxiao)
	ON_BN_CLICKED(IDC_BUTTON11, Onshuchutongjijieguo)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CChengjitongjiDlg message handlers

BOOL CChengjitongjiDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Add "About..." menu item to system menu.

	// IDM_ABOUTBOX must be in the system command range.
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		CString strAboutMenu;
		strAboutMenu.LoadString(IDS_ABOUTBOX);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	m_chaxunleibie.AddString("姓名:");
	m_chaxunleibie.AddString("学号:");
	m_shanchuleibie.AddString("全部:");
	m_shanchuleibie.AddString("姓名:");
	m_shanchuleibie.AddString("学号:");
	m_xiugaileibie.AddString("姓名:");
	m_xiugaileibie.AddString("学号:");
    m_xianshileibie.AddString("原序:");
	m_xianshileibie.AddString("学号:");
    m_xianshileibie.AddString("最终成绩:");
	m_tongjiqujian.AddString("90分以上");
	m_tongjiqujian.AddString("80-90分");
    m_tongjiqujian.AddString("70-80分");
	m_tongjiqujian.AddString("60-70分");
	m_tongjiqujian.AddString("60分以下");

	// TODO: Add extra initialization here
	
	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CChengjitongjiDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
	{
		CAboutDlg dlgAbout;
		dlgAbout.DoModal();
	}
	else
	{
		CDialog::OnSysCommand(nID, lParam);
	}
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CChengjitongjiDlg::OnPaint() 
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CChengjitongjiDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}

void CChengjitongjiDlg::Ontianjia() 
{
	//static int i=1;
	//int i;
	CString Nname,Nnumber,Naverage,Nmiddle,Nfinal;
	m_name.GetWindowText(Nname);
	m_number.GetWindowText(Nnumber);
	m_average.GetWindowText(Naverage);
	m_middle.GetWindowText(Nmiddle);
    m_final.GetWindowText(Nfinal);
    
	ScoreNode *newnode=new ScoreNode;
    ConsScoreNode(Nname,Nnumber,Naverage,Nmiddle,Nfinal,Nresultemp,newnode);
	ScoreNode *newnoden=new ScoreNode();
	newnoden=newnode;
	 //AfxMessageBox((newnoden->data).name+"worinima!");
	if(score.Searchname(Nname)==-1)
	score.Product(newnoden,j);
	else
		AfxMessageBox("Already Get Down!");

    
	 m_name.SetWindowText("");
	 m_number.SetWindowText("");
	 m_average.SetWindowText("");
	 m_middle.SetWindowText("");
     //m_final.ResetContent();
	 m_final.SetWindowText("");
	 m_result.SetWindowText("");
	// TODO: Add your control notification handler code here
	//score.GetLength();	
}

void CChengjitongjiDlg::Onqueding() 
{
    CString Nname,Nnumber,Naverage,Nmiddle,Nfinal;
	m_name.GetWindowText(Nname);
	m_number.GetWindowText(Nnumber);
	m_average.GetWindowText(Naverage);
	m_middle.GetWindowText(Nmiddle);
    m_final.GetWindowText(Nfinal);

    int a,b,c,d;
	a=atoi(Naverage); 
    b=atoi(Nmiddle);
	c=atoi(Nfinal);
	if(a<=0||a>100||b<=0||b>100||c<=0||c>100)
	{AfxMessageBox("Error!");
	 m_name.SetWindowText("");
	 m_number.SetWindowText("");
	 m_average.SetWindowText("");
	 m_middle.SetWindowText("");
     m_result.SetWindowText("");
	 m_final.SetWindowText("");
	 AfxMessageBox("Please input again!");
	}
	 else
	 {d=a*0.2+b*0.2+c*0.6;
	  Nresultemp=d;
	
      CString Nresult; 
     
      Nresult.Format("%d",d); 
	m_result.SetWindowText(Nresult);
      Nresultemp=Nresult;}
}

void ConsScoreNode(CString Nname,CString Nnumber,CString Naverage,CString Nmiddle,CString Nfinal,CString Nresultemp,ScoreNode* newnode)
{   
	//ScoreNode *scoreNode;
	(newnode->data).name=Nname;
	(newnode->data).number=Nnumber;
	(newnode->data).average=Naverage;
	(newnode->data).middle=Nmiddle;
	(newnode->data).final=Nfinal;
	(newnode->data).result=Nresultemp;
    newnode->next=NULL;
	newnode->prior=NULL;
	AfxMessageBox((newnode->data).name);
    //return newnode;
}

void CChengjitongjiDlg::Onxianshiyiyoujilu() 
{
	CString Nshowtype;
	m_xianshileibie.GetWindowText(Nshowtype);
	if(Nshowtype=="原序:")
		{
			ScoreNode *current=new ScoreNode();
			current=score.Gethead();
					while(current->next!=score.GetEnd())
				{	
	                m_show.AddString((current->next->data).name+",  "+(current->next->data).number+",  "+(current->next->data).average+",  "
		             +(current->next->data).middle+",  "+(current->next->data).result);
	            	AfxMessageBox("here!");
	                current=current->next;

					}
					
                }
	else if(Nshowtype=="学号:")
		{
			AfxMessageBox("herele");
			score.ordernumber(1);
			ScoreNode *current=new ScoreNode();
			current=score.Gethead();
					while(current->next!=score.GetEnd())
				{	
	                m_show.AddString((current->next->data).name+",  "+(current->next->data).number+",  "+(current->next->data).average+",  "
		             +(current->next->data).middle+",  "+(current->next->data).result);
	            	AfxMessageBox("here!");
	                current=current->next;

					}
	}
	else
		{
			score.ordernumber(2);
			ScoreNode *current=new ScoreNode();
			current=score.Gethead();
					while(current->next!=score.GetEnd())
				{	
	                m_show.AddString((current->next->data).name+",  "+(current->next->data).number+",  "+(current->next->data).average+",  "
		             +(current->next->data).middle+",  "+(current->next->data).result);
	            	AfxMessageBox("here!");
	                current=current->next;

					}
}
}
		
	// TODO: Add your control notification handler code here
	


void CChengjitongjiDlg::Onchaxun() 
{   int i;
	ScoreNode* current=0;
	CString Ntype,Nname;
	m_chaxunleibie.GetWindowText(Ntype);
	if(Ntype=="姓名:")
	{
		m_chaxun.GetWindowText(Nname);
	i=score.Searchname(Nname);
		if(i==-1)
		{
			AfxMessageBox("No such person!");
		}
		else
		{
			current=score.Getscorenode(i);
			m_show.AddString((current->data).name+" ,  "+(current->data).number+" ,  "+(current->data).average+" ,  "
		  +(current->data).middle+" , "+(current->data).result);
		}
	// TODO: Add your control notification handler code here
	
	}
	else
	{
		m_chaxun.GetWindowText(Nname);
	i=score.Searchnumber(Nname);
	if(i==-1)
		{
			AfxMessageBox("No such person!");
		}
		else
		{
			current=score.Getscorenode(i);
			m_show.AddString((current->data).name+" ,  "+(current->data).number+" ,  "+(current->data).average+" ,  "
		  +(current->data).middle+" , "+(current->data).result);
		}
}
}
void CChengjitongjiDlg::Onxianshifuwei() 
{
m_show.ResetContent();	// TODO: Add your control notification handler code here
	
}

void CChengjitongjiDlg::Onshanchu() 
{
	CString Ntype,Nname;
	int i;
	m_shanchuleibie.GetWindowText(Ntype);
	if((Ntype=="全部:")&&(!score.IsEmpty()))
	{
		score.Erase();
		AfxMessageBox("All have been deleted!");
		
	}
	else if((Ntype=="姓名:")&&(!score.IsEmpty()))
	{
		m_chaxun.GetWindowText(Nname);
		i=score.Searchname(Nname);
		if(i==-1)
		{
			AfxMessageBox("No such person!");
		}
		else
		{
			score.Delete(i);
			AfxMessageBox("Have been already deleted!");
		}
	}
	else  if((Ntype=="最终成绩:")&&(!score.IsEmpty()))
	{
		m_chaxun.GetWindowText(Nname);
		i=score.Searchnumber(Nname);
		if(i==-1)
		{
			AfxMessageBox("No such person!");
		}
		else
		{
			score.Delete(i);
			AfxMessageBox("Have been already deleted!");
		}
	}
	else
	{
		AfxMessageBox("There is no record to be deleted!");
	}
}

void CChengjitongjiDlg::Onxiugaijilu() 
{
	CString Ntype,Nname;
	int i;
    ScoreNode* current=0;
	m_xiugaileibie.GetWindowText(Ntype);
	if(score.IsEmpty())
	{
		AfxMessageBox("Nothing to be modified!");
	}
	else
	{
		if(Ntype=="姓名:")
		{
		m_xiugai.GetWindowText(Nname);
		i=score.Searchname(Nname);
			if(i==-1)
			{
				AfxMessageBox("No such person!");
			}
			else
			{
				score.Delete(i);
			AfxMessageBox("Please input the new data:");
			j=1;
		
			}
		}
		else  
	{

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -