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

📄 saishiframe.cpp

📁 由我为校教务处自主开发的竞赛计分软件。 该软件由“比赛信息管理”、“裁判信息管理”、“选手信息管理”、“比赛计分排序”等几个模块组成。基于MFC技术
💻 CPP
字号:
// saishiframe.cpp : 实现文件
//

#include "stdafx.h"
#include "计分程序 by WS.h"
#include "saishiframe.h"
#include ".\saishiframe.h"



// saishiframe 对话框

IMPLEMENT_DYNAMIC(saishiframe, CDialog)
saishiframe::saishiframe(CWnd* pParent /*=NULL*/)
	: CDialog(saishiframe::IDD, pParent)

{
	
}

saishiframe::~saishiframe()
{
	db.databaseclose();
	
}

void saishiframe::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_LIST1, saishi);
	DDX_Control(pDX, IDC_EDIT1, saishimingcheng);
	DDX_Control(pDX, IDC_EDIT2, saishiriqi);
	DDX_Control(pDX, IDC_EDIT3, saishididian);
	DDX_Control(pDX, IDC_EDIT4, pingwei1);
	DDX_Control(pDX, IDC_EDIT5, pingwei1bili);
	DDX_Control(pDX, IDC_EDIT6, pingwei1renshu);
	DDX_Control(pDX, IDC_EDIT7, pingwei2);
	DDX_Control(pDX, IDC_EDIT8, pingwei2bili);
	DDX_Control(pDX, IDC_EDIT9, pingwei2renshu);
	DDX_Control(pDX, IDC_EDIT10, pingwei3);
	DDX_Control(pDX, IDC_EDIT11, pingwei3bili);
	DDX_Control(pDX, IDC_EDIT12, pingwei3renshu);
	DDX_Control(pDX, IDC_EDIT13, saishixuhao);
	DDX_Control(pDX, IDC_EDIT14, zhuangtai);

	DDX_Control(pDX, IDC_EDIT15, shanchufenshu);
	DDX_Control(pDX, IDC_EDIT16, cansaixiangmushu);
}


BEGIN_MESSAGE_MAP(saishiframe, CDialog)

ON_LBN_SELCHANGE(IDC_LIST1, OnLbnSelchangeList1)
ON_BN_CLICKED(IDC_BUTTON3, OnBnClickedButton3)
ON_BN_CLICKED(IDC_BUTTON4, OnBnClickedButton4)
ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
//ON_BN_CLICKED(IDOK, OnBnClickedOk)
//ON_BN_CLICKED(IDOK, OnBnClickedOk)
ON_BN_SETFOCUS(IDC_BUTTON4, OnBnSetfocusButton4)
ON_WM_SIZE()
ON_WM_PAINT()
END_MESSAGE_MAP()


// saishiframe 消息处理程序





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

	// TODO:  在此添加额外的初始化
	
	db.databaseconn();
	db.datasearcher();
	if(!db.getrs()->adoeof){
		CString tempsaishi;
		while(!db.getrs()->adoeof){
		tempsaishi=db.getrs()->GetFields()->GetItem("mingcheng")->GetValue();
		saishi.AddString(tempsaishi);
		db.getrs()->MoveNext();
		}
	}
	else{
		CString  names;
		names="暂时无记录";
		saishi.AddString(names);
		}
	return TRUE;  // return TRUE unless you set the focus to a control
	// 异常: OCX 属性页应返回 FALSE
}

void saishiframe::OnLbnSelchangeList1()
{
	// TODO: 在此添加控件通知处理程序代码
	CString tempname,xuhaotemp;
	int tempindex = saishi.GetCurSel();
	if (tempindex!=LB_ERR){
	saishi.GetText(tempindex,tempname);
	}
	CString sql="select * from saishi where mingcheng='"+tempname+"'";
	db.datasearcher(sql);
	if(!db.getrs()->adoeof){
			CString tsql;
			tempname=db.getrs()->GetFields()->GetItem("xuhao")->GetValue();
			saishixuhao.SetWindowText(tempname);
			tempname=db.getrs()->GetFields()->GetItem("mingcheng")->GetValue();
			saishimingcheng.SetWindowText(tempname);
			tempname=db.getrs()->GetFields()->GetItem("riqi")->GetValue();
			saishiriqi.SetWindowText(tempname);
			tempname=db.getrs()->GetFields()->GetItem("didian")->GetValue();
			saishididian.SetWindowText(tempname);
			tempname=db.getrs()->GetFields()->GetItem("pingwei1")->GetValue();
			pingwei1.SetWindowText(tempname);
			tempname=db.getrs()->GetFields()->GetItem("pingwei1renshu")->GetValue();
			pingwei1renshu.SetWindowText(tempname);
			tempname=db.getrs()->GetFields()->GetItem("pingwei1bili")->GetValue();
			pingwei1bili.SetWindowText(tempname);
			tempname=db.getrs()->GetFields()->GetItem("pingwei2")->GetValue();
			pingwei2.SetWindowText(tempname);
			tempname=db.getrs()->GetFields()->GetItem("pingwei2renshu")->GetValue();
			pingwei2renshu.SetWindowText(tempname);
			tempname=db.getrs()->GetFields()->GetItem("pingwei2bili")->GetValue();
			pingwei2bili.SetWindowText(tempname);
			tempname=db.getrs()->GetFields()->GetItem("pingwei3")->GetValue();
			pingwei3.SetWindowText(tempname);
			tempname=db.getrs()->GetFields()->GetItem("pingwei3renshu")->GetValue();
			pingwei3renshu.SetWindowText(tempname);
			tempname=db.getrs()->GetFields()->GetItem("pingwei3bili")->GetValue();
			pingwei3bili.SetWindowText(tempname);
			tempname=db.getrs()->GetFields()->GetItem("shanchufenshu")->GetValue();
			shanchufenshu.SetWindowText(tempname);
			tempname=db.getrs()->GetFields()->GetItem("xiangmushu")->GetValue();
			cansaixiangmushu.SetWindowText(tempname);
			zhuangtai.SetWindowText("成功读取记录");
	}            
}

void saishiframe::OnBnClickedButton3()
{
	// TODO: 在此添加控件通知处理程序代码
	CString tempname,tempname1;
	saishixuhao.GetWindowText(tempname);
	if (tempname!=""){
	CString sql="select * from saishi where xuhao="+tempname+"";
	db.datasearcher(sql);
	try{
	saishimingcheng.GetWindowText(tempname1);
	db.getrs()->GetFields()->GetItem("mingcheng")->PutValue(_variant_t(tempname1));

	saishididian.GetWindowText(tempname1);
	db.getrs()->GetFields()->GetItem("didian")->PutValue(_variant_t(tempname1));

	saishiriqi.GetWindowText(tempname1);
	db.getrs()->GetFields()->GetItem("riqi")->PutValue(_variant_t(tempname1));

	pingwei1.GetWindowText(tempname1);
	db.getrs()->GetFields()->GetItem("pingwei1")->PutValue(_variant_t(tempname1));

	pingwei1bili.GetWindowText(tempname1);
	if (tempname1=="") tempname1="100";
	db.getrs()->GetFields()->GetItem("pingwei1bili")->PutValue(_variant_t(tempname1));

	pingwei2.GetWindowText(tempname1);
	db.getrs()->GetFields()->GetItem("pingwei2")->PutValue(_variant_t(tempname1));

	pingwei2bili.GetWindowText(tempname1);
	if (tempname1=="") tempname1="0";
	db.getrs()->GetFields()->GetItem("pingwei2bili")->PutValue(_variant_t(tempname1));

	pingwei3bili.GetWindowText(tempname1);
	if (tempname1=="") tempname1="0";
	db.getrs()->GetFields()->GetItem("pingwei3bili")->PutValue(_variant_t(tempname1));

	pingwei3.GetWindowText(tempname1);
	db.getrs()->GetFields()->GetItem("pingwei3")->PutValue(_variant_t(tempname1));

	shanchufenshu.GetWindowText(tempname1);
	if (tempname1=="") tempname1="1";
	db.getrs()->GetFields()->GetItem("shanchufenshu")->PutValue(_variant_t(tempname1));

	db.getrs()->Update();
	zhuangtai.SetWindowText("数据修改成功");
	}
	catch(_com_error e){
	AfxMessageBox("请检查\n您输入的数据类型");
	}
	
	saishi.ResetContent();
	db.datasearcher();
	
				while(!db.getrs()->adoeof){
				CString tempsaishi;
				tempsaishi=db.getrs()->GetFields()->GetItem("mingcheng")->GetValue();	
				saishi.AddString(tempsaishi);
				db.getrs()->MoveNext();
				}
	
				
	
	}
	else{
		zhuangtai.SetWindowText("您还没有选择数据");
	}
	}
	
	


void saishiframe::OnBnClickedButton4()
{
	// TODO: 在此添加控件通知处理程序代码
	CString tempname,tempname1;
	saishimingcheng.GetWindowText(tempname);
	if (tempname!=""){
	CString sql="select top 1 * from saishi where mingcheng = '"+tempname+"'";
	try{
	db.datasearcher(sql);
	if (db.getrs()->adoeof)	{
			db.getrs()->AddNew();
			saishimingcheng.GetWindowText(tempname1);
			db.getrs()->GetFields()->GetItem("mingcheng")->PutValue(_variant_t(tempname1));

			saishididian.GetWindowText(tempname1);
			db.getrs()->GetFields()->GetItem("didian")->PutValue(_variant_t(tempname1));

			saishiriqi.GetWindowText(tempname1);
			db.getrs()->GetFields()->GetItem("riqi")->PutValue(_variant_t(tempname1));

			pingwei1.GetWindowText(tempname1);
			db.getrs()->GetFields()->GetItem("pingwei1")->PutValue(_variant_t(tempname1));

			pingwei1bili.GetWindowText(tempname1);
			if (tempname1=="") tempname1="100";
			db.getrs()->GetFields()->GetItem("pingwei1bili")->PutValue(_variant_t(tempname1));

			pingwei2.GetWindowText(tempname1);
			db.getrs()->GetFields()->GetItem("pingwei2")->PutValue(_variant_t(tempname1));

			pingwei2bili.GetWindowText(tempname1);
			if (tempname1=="") tempname1="0";
			db.getrs()->GetFields()->GetItem("pingwei2bili")->PutValue(_variant_t(tempname1));

			pingwei3bili.GetWindowText(tempname1);
			if (tempname1=="") tempname1="0";
			db.getrs()->GetFields()->GetItem("pingwei3bili")->PutValue(_variant_t(tempname1));

			pingwei3.GetWindowText(tempname1);
			db.getrs()->GetFields()->GetItem("pingwei3")->PutValue(_variant_t(tempname1));

			shanchufenshu.GetWindowText(tempname1);
			if (tempname1=="") tempname1="1";
			db.getrs()->GetFields()->GetItem("shanchufenshu")->PutValue(_variant_t(tempname1));
			
			db.getrs()->Update();
			zhuangtai.SetWindowText("数据添加成功");
		}
	
	else{
		zhuangtai.SetWindowText("比赛信息已存在,添加失败");
	}
	}
	catch(_com_error e){
	AfxMessageBox("请检查\n您输入的数据类型\n并且数据是否完整");
	}
	
	saishi.ResetContent();
	db.datasearcher();
	
				while(!db.getrs()->adoeof){
				CString tempsaishi;
				tempsaishi=db.getrs()->GetFields()->GetItem("mingcheng")->GetValue();	
				saishi.AddString(tempsaishi);
				db.getrs()->MoveNext();
				}
	
				
	
	}
}

void saishiframe::OnBnClickedButton1()
{
	// TODO: 在此添加控件通知处理程序代码
	CString tempname;
	saishixuhao.GetWindowText(tempname);
	if (tempname!=""){
	CString sql="select top 1 * from saishi where xuhao="+tempname;
	db.datasearcher(sql);
	try{
		db.getrs()->Delete(adAffectCurrent);
		CString sql="select * from pingwei where suoshusaishi="+tempname;
		db.datasearcher(sql);
		if (!db.getrs()->adoeof){
			while (!db.getrs()->adoeof){
			db.getrs()->Delete(adAffectCurrent);
			db.getrs()->MoveNext();
			}
		}
		sql="select * from xuanshou where suoshusaishi="+tempname;
		db.datasearcher(sql);
		if (!db.getrs()->adoeof){
		while (!db.getrs()->adoeof){
			db.getrs()->Delete(adAffectCurrent);
			db.getrs()->MoveNext();
			}
		}
		sql="select * from chengji where suoshusaishi="+tempname;
		db.datasearcher(sql);
		if (!db.getrs()->adoeof){
		while (!db.getrs()->adoeof){
			db.getrs()->Delete(adAffectCurrent);
			db.getrs()->MoveNext();
			}
		}
		sql="select * from fenshu where suoshusaishi="+tempname;
		db.datasearcher(sql);
		if (!db.getrs()->adoeof){
		while (!db.getrs()->adoeof){
			db.getrs()->Delete(adAffectCurrent);
			db.getrs()->MoveNext();
			}
		}
		zhuangtai.SetWindowText("数据删除成功");
		saishixuhao.SetWindowText("");
		saishimingcheng.SetWindowText("");
		saishididian.SetWindowText("");
		saishiriqi.SetWindowText("");
		pingwei1.SetWindowText("");
		pingwei1bili.SetWindowText("");
		pingwei2.SetWindowText("");
		pingwei2bili.SetWindowText("");
		pingwei3bili.SetWindowText("");
		pingwei3.SetWindowText("");
		shanchufenshu.SetWindowText("");
		saishi.ResetContent();
	OnInitDialog();
	}
	catch(_com_error e){
	zhuangtai.SetWindowText("数据没有被删除");
	}
	}
	else{
		zhuangtai.SetWindowText("请选择要删除的数据");
	}
}

void saishiframe::OnBnSetfocusButton4()
{
	// TODO: 在此添加控件通知处理程序代码

}

void saishiframe::OnOK()
{
	// TODO: 在此添加专用代码和/或调用基类

	
}

void saishiframe::OnSize(UINT nType, int cx, int cy)
{
	CDialog::OnSize(nType, cx, cy);

	// TODO: 在此处添加消息处理程序代码
}

void saishiframe::OnPaint()
{
	CPaintDC dc(this); // device context for painting
	// TODO: 在此处添加消息处理程序代码
	// 不为绘图消息调用 CDialog::OnPaint()
}

⌨️ 快捷键说明

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