📄 pingweiku.cpp
字号:
// pingweiku.cpp : 实现文件
//
#include "stdafx.h"
#include "计分程序 by WS.h"
#include "pingweiku.h"
#include ".\pingweiku.h"
// pingweiku 对话框
IMPLEMENT_DYNAMIC(pingweiku, CDialog)
pingweiku::pingweiku(CWnd* pParent /*=NULL*/)
: CDialog(pingweiku::IDD, pParent)
, shifouxianshi(FALSE)
{
}
pingweiku::~pingweiku()
{
db.databaseclose();
}
void pingweiku::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_LIST1, saishi);
DDX_Control(pDX, IDC_STATIC_zhuangtai, zhuangtai);
DDX_Control(pDX, IDC_LIST2, pingweizu);
DDX_Control(pDX, IDC_EDIT3, saishixuhao);
DDX_Control(pDX, IDC_LIST3, pingwei);
DDX_Control(pDX, IDC_EDIT1, pingweiming);
DDX_Control(pDX, IDC_CHECK1, xianshiming);
DDX_Control(pDX, IDC_EDIT2, jianjie);
DDX_Check(pDX, IDC_CHECK1, shifouxianshi);
DDX_Control(pDX, IDC_EDIT4, pingweixuhao);
DDX_Control(pDX, IDC_STATIC_zhuangtai1, zhuangtai1);
DDX_Control(pDX, IDC_LIST4, suoyoupingwei);
}
BEGIN_MESSAGE_MAP(pingweiku, CDialog)
ON_BN_CLICKED(IDOK, OnBnClickedOk)
ON_LBN_SELCHANGE(IDC_LIST1, OnLbnSelchangeList1)
ON_LBN_SELCHANGE(IDC_LIST2, OnLbnSelchangeList2)
ON_EN_CHANGE(IDC_EDIT2, OnEnChangeEdit2)
ON_LBN_SELCHANGE(IDC_LIST3, OnLbnSelchangeList3)
ON_BN_CLICKED(IDC_BUTTON3, OnBnClickedButton3)
ON_BN_CLICKED(IDC_BUTTON4, OnBnClickedButton4)
ON_BN_CLICKED(IDC_BUTTON6, OnBnClickedButton6)
ON_LBN_SELCHANGE(IDC_LIST4, OnLbnSelchangeList4)
END_MESSAGE_MAP()
// pingweiku 消息处理程序
BOOL pingweiku::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);
}
CString sql ="select distinct xingming from pingweiku";
db.datasearcher(sql);
while(!db.getrs()->adoeof){
CString tempname=db.getrs()->GetFields()->GetItem("xingming")->GetValue();
suoyoupingwei.AddString(tempname);
db.getrs()->MoveNext();
}
return TRUE; // return TRUE unless you set the focus to a control
// 异常: OCX 属性页应返回 FALSE
}
void pingweiku::OnBnClickedOk()
{
// TODO: 在此添加控件通知处理程序代码
OnOK();
}
void pingweiku::OnLbnSelchangeList1()
{
// TODO: 在此添加控件通知处理程序代码
CString tempname;
int tempindex = saishi.GetCurSel();
if (tempindex!=LB_ERR){
saishi.GetText(tempindex,tempname);
zhuangtai1.SetWindowText(tempname);
pingweizu.ResetContent();
}
CString sql="select * from saishi where mingcheng='"+tempname+"'";
db.datasearcher(sql);
try{
if(!db.getrs()->adoeof){
tempname=db.getrs()->GetFields()->GetItem("xuhao")->GetValue();
if (tempname!=""){
saishixuhao.SetWindowText(tempname);
}
tempname=db.getrs()->GetFields()->GetItem("pingwei1")->GetValue();
if (tempname!=""){
pingweizu.AddString(tempname);
}
tempname=db.getrs()->GetFields()->GetItem("pingwei2")->GetValue();
if (tempname!=""){
pingweizu.AddString(tempname);
}
tempname=db.getrs()->GetFields()->GetItem("pingwei3")->GetValue();
if (tempname!=""){
pingweizu.AddString(tempname);
}
CString tempxuhao;
saishixuhao.GetWindowText(tempxuhao);
sql="select * from pingwei where suoshusaishi="+tempxuhao+"";
try{
db.datasearcher(sql);
pingwei.ResetContent();
if(db.getrs()->adoeof){pingwei.AddString("无记录");}
}
catch(_com_error e){
AfxMessageBox("数据库访问出错");
}
}
}
catch(_com_error e){
AfxMessageBox("数据库访问出错");
}
}
void pingweiku::OnOK()
{
// TODO: 在此添加专用代码和/或调用基类
}
void pingweiku::OnLbnSelchangeList2()
{
// TODO: 在此添加控件通知处理程序代码
CString tempname,tempxuhao;
saishixuhao.GetWindowText(tempxuhao);
int tempindex= pingweizu.GetCurSel();
if (tempindex!=LB_ERR){
pingweizu.GetText(tempindex,tempname);
pingwei.ResetContent();
}
CString sql="select * from pingwei where suoshupingweizu = '"+tempname+"' and suoshusaishi="+tempxuhao+"";
try{
db.datasearcher(sql);
if(db.getrs()->adoeof){pingwei.AddString("无记录");}
while(!db.getrs()->adoeof){
tempname=db.getrs()->GetFields()->GetItem("xingming")->GetValue();
pingwei.AddString(tempname);
db.getrs()->MoveNext();
}
}
catch(_com_error e){
AfxMessageBox("数据库访问出错");
}
}
void pingweiku::OnEnChangeEdit2()
{
// TODO: 如果该控件是 RICHEDIT 控件,则它将不会
// 发送该通知,除非重写 CDialog::OnInitDialog()
// 函数并调用 CRichEditCtrl().SetEventMask(),
// 同时将 ENM_CHANGE 标志“或”运算到掩码中。
// TODO: 在此添加控件通知处理程序代码
}
void pingweiku::OnLbnSelchangeList3()
{
// TODO: 在此添加控件通知处理程序代码
CString tempname,tempxuhao,tempname1;
saishixuhao.GetWindowText(tempxuhao);
int tempindex= pingwei.GetCurSel();
int tempindex1= pingweizu.GetCurSel();
if (tempindex!=LB_ERR&&tempindex1!=LB_ERR){
pingwei.GetText(tempindex,tempname);
pingweizu.GetText(tempindex1,tempname1);
}
CString sql="select top 1 * from pingwei where xingming = '"+tempname+"' and suoshusaishi="+tempxuhao+" and suoshupingweizu='"+tempname1+"'";
try{
db.datasearcher(sql);
if(!db.getrs()->adoeof){
tempname=db.getrs()->GetFields()->GetItem("xuhao")->GetValue();
pingweixuhao.SetWindowText(tempname);
tempname=db.getrs()->GetFields()->GetItem("xingming")->GetValue();
pingweiming.SetWindowText(tempname);
tempname=db.getrs()->GetFields()->GetItem("jianjie")->GetValue();
jianjie.SetWindowText(tempname);
bool tempcheck = db.getrs()->GetFields()->GetItem("xianshi")->GetValue();
if(tempcheck==false){
shifouxianshi=false;
UpdateData(FALSE);
}
if(tempcheck==true){
shifouxianshi=true;
UpdateData(FALSE);
}
zhuangtai.SetWindowText("数据读取成功");
}
}
catch(_com_error e){
AfxMessageBox("数据库访问出错");
}
}
void pingweiku::OnBnClickedButton3()
{
// TODO: 在此添加控件通知处理程序代码
CString tempname,tempxuhao,insertzu;
long pingweishutemp;
saishixuhao.GetWindowText(tempxuhao);
pingweiming.GetWindowText(tempname);
int tempindex= pingweizu.GetCurSel();
if (tempindex!=LB_ERR){
pingweizu.GetText(tempindex,insertzu);
}
CString tsql="select * from pingwei where suoshusaishi="+tempxuhao+" and suoshupingweizu='"+insertzu+"'";
pingweishutemp=db.getrscount(tsql);
if(pingweishutemp<30){
if (tempname!=""&&tempxuhao!=""&&insertzu!=""){
CString sql="select top 1 * from pingwei where xingming='"+tempname+"' and suoshupingweizu='"+insertzu+"' and suoshusaishi="+tempxuhao+"";
try{
db.datasearcher(sql);
if(db.getrs()->adoeof){
db.getrs()->AddNew();
pingweiming.GetWindowText(tempname);
db.getrs()->GetFields()->GetItem("xingming")->PutValue(_variant_t(tempname));
db.getrs()->GetFields()->GetItem("suoshupingweizu")->PutValue(_variant_t(insertzu));
db.getrs()->GetFields()->GetItem("suoshusaishi")->PutValue(_variant_t(tempxuhao));
jianjie.GetWindowText(tempname);
db.getrs()->GetFields()->GetItem("jianjie")->PutValue(_variant_t(tempname));
if(xianshiming.GetCheck()){db.getrs()->GetFields()->GetItem("xianshi")->PutValue(true);}
if(!xianshiming.GetCheck()){db.getrs()->GetFields()->GetItem("xianshi")->PutValue(false);}
db.getrs()->Update();
pingweiming.GetWindowText(tempname);
sql="select top 1 * from pingweiku where xingming='"+tempname+"'";
db.datasearcher(sql);
if(db.getrs()->adoeof){
db.getrs()->AddNew();
db.getrs()->GetFields()->GetItem("xingming")->PutValue(_variant_t(tempname));
db.getrs()->Update();
}
OnLbnSelchangeList2();
zhuangtai.SetWindowText("数据添加成功");
suoyoupingwei.ResetContent();
saishi.ResetContent();
OnInitDialog();
}
else{
zhuangtai.SetWindowText("数据添加失败,数据重复");
}
}
catch(_com_error e){
AfxMessageBox("数据库访问出错");
}
}
else{
zhuangtai.SetWindowText("数据添加失败,请检查数据完整性");
}
}
else{
zhuangtai.SetWindowText("此评委组已满30人");
}
}
void pingweiku::OnBnClickedButton4()
{
// TODO: 在此添加控件通知处理程序代码
CString tempname,tempxuhao,insertzu,temppingweixuhao;
saishixuhao.GetWindowText(tempxuhao);
pingweiming.GetWindowText(tempname);
pingweixuhao.GetWindowText(temppingweixuhao);
int tempindex= pingweizu.GetCurSel();
if (tempindex!=LB_ERR){
pingweizu.GetText(tempindex,insertzu);
}
if (tempname!=""&&tempxuhao!=""&&insertzu!=""&&temppingweixuhao!=""){
CString sql="select top 1 * from pingwei where xuhao="+temppingweixuhao+"";
try{
db.datasearcher(sql);
if(!db.getrs()->adoeof){
pingweiming.GetWindowText(tempname);
db.getrs()->GetFields()->GetItem("xingming")->PutValue(_variant_t(tempname));
db.getrs()->GetFields()->GetItem("suoshupingweizu")->PutValue(_variant_t(insertzu));
db.getrs()->GetFields()->GetItem("suoshusaishi")->PutValue(_variant_t(tempxuhao));
jianjie.GetWindowText(tempname);
db.getrs()->GetFields()->GetItem("jianjie")->PutValue(_variant_t(tempname));
if(xianshiming.GetCheck()){db.getrs()->GetFields()->GetItem("xianshi")->PutValue(true);}
if(!xianshiming.GetCheck()){db.getrs()->GetFields()->GetItem("xianshi")->PutValue(false);}
db.getrs()->Update();
saishixuhao.GetWindowText(tempxuhao);
if (tempxuhao!=""){
sql ="select * from pingwei where suoshusaishi ="+tempxuhao;
db.datasearcher(sql);
while(!db.getrs()->adoeof){
if(xianshiming.GetCheck()){db.getrs()->GetFields()->GetItem("xianshi")->PutValue(true);}
if(!xianshiming.GetCheck()){db.getrs()->GetFields()->GetItem("xianshi")->PutValue(false);}
db.getrs()->Update();
db.getrs()->MoveNext();
}
}
zhuangtai.SetWindowText("数据修改成功");
OnLbnSelchangeList2();
}
else{
zhuangtai.SetWindowText("数据修改失败,无此记录");
}
}
catch(_com_error e){
AfxMessageBox("数据库访问出错");
}
}
else{
zhuangtai.SetWindowText("数据修改失败,请检查数据完整性");
}
}
void pingweiku::OnBnClickedButton6()
{
// TODO: 在此添加控件通知处理程序代码
CString temppingweixuhao;
pingweixuhao.GetWindowText(temppingweixuhao);
if (temppingweixuhao!=""){
CString sql="select top 1 * from pingwei where xuhao="+temppingweixuhao+"";
try{
db.datasearcher(sql);
if(!db.getrs()->adoeof){
db.getrs()->Delete(adAffectCurrent);
pingweixuhao.SetWindowText("");
pingweiming.SetWindowText("");
jianjie.SetWindowText("");
shifouxianshi=false;
UpdateData(0);
zhuangtai.SetWindowText("数据删除成功");
pingwei.ResetContent();
OnLbnSelchangeList2();
}
else{
zhuangtai.SetWindowText("数据删除失败,无此记录");
}
}
catch(_com_error e){
AfxMessageBox("数据库访问出错");
}
}
else{
zhuangtai.SetWindowText("数据删除失败");
}
}
void pingweiku::OnLbnSelchangeList4()
{
// TODO: 在此添加控件通知处理程序代码
int tempindex;
tempindex=suoyoupingwei.GetCurSel();
if(tempindex!=LB_ERR){
CString tempname;
suoyoupingwei.GetText(tempindex,tempname);
pingweiming.SetWindowText(tempname);
}
suoyoupingwei.ResetContent();
saishi.ResetContent();
OnInitDialog();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -