📄 xuqiuvsduixiang4.cpp
字号:
// xuqiuVSduixiang4.cpp : implementation file
//
#include "stdafx.h"
#include "qfd.h"
#include "xuqiuVSduixiang4.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CxuqiuVSduixiang4 dialog
CxuqiuVSduixiang4::CxuqiuVSduixiang4(CWnd* pParent /*=NULL*/)
: CDialog(CxuqiuVSduixiang4::IDD, pParent)
{
//{{AFX_DATA_INIT(CxuqiuVSduixiang4)
m_xishu = 0;
//}}AFX_DATA_INIT
}
void CxuqiuVSduixiang4::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CxuqiuVSduixiang4)
DDX_Control(pDX, IDC_DATALIST1, m_list1);
DDX_Control(pDX, IDC_DATALIST2, m_list2);
DDX_Text(pDX, IDC_EDIT1, m_xishu);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CxuqiuVSduixiang4, CDialog)
//{{AFX_MSG_MAP(CxuqiuVSduixiang4)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CxuqiuVSduixiang4 message handlers
void CxuqiuVSduixiang4::OnButton1()
{
UpdateData(true);//更新编辑框,并且将当前编辑框的数值赋给m_xishu
int index1=0,index2=0;
CString term1,term2;
term1=m_list1.GetText();
term2=m_list2.GetText();
CString strSQL1;
strSQL1.Format("select * from 工程措施3 where 工程措施='%s' \
",\
term1
);
//打开记录集 选择表名
if(!OpenRecordSet(m_pRecordset,strSQL1))
{
AfxMessageBox("没有成功打开数据表");
return;
}
CString cindex1=VariantToCString(m_pRecordset->GetCollect("ID"));
index1=atoi(cindex1);
//关闭
m_pRecordset->Close();
m_pRecordset=NULL;
CString strSQL2;
strSQL2.Format("select * from 比较对象 where 比较对象='%s' \
",\
term2
);
//打开记录集 选择表名
if(!OpenRecordSet(m_pRecordset,strSQL2))
{
AfxMessageBox("没有成功打开数据表");
return;
}
CString cindex2=VariantToCString(m_pRecordset->GetCollect("ID"));
index2=atoi(cindex2);
//关闭
m_pRecordset->Close();
m_pRecordset=NULL;
// m_xishu=index1;
//UpdateData(false); //更新编辑框,但不将当前编辑框的数值赋给m_xishu
// AfxMessageBox(term1 + " "+ term2+" " + cindex1+ " " +cindex2);
CString strSQL3;
CString a;
switch(index1){
case 1:
strSQL3.Format("select a from 需求和比较对象关系表4 where ID='%s' \
",\
cindex2);
if(!OpenRecordSet(m_pRecordset,strSQL3))
{
AfxMessageBox("没有成功打开数据表");
return;
}
a.Format("%d",m_xishu);
//上述准备完毕,下面开始插入内容
try
{
m_pRecordset->PutCollect("a",_variant_t(a));
//更新数据库
m_pRecordset->Update();
}
catch(_com_error e)
{
CString strError;
strError.Format("警告: 插入信息时发生异常。 错误信息: %s",\
e.ErrorMessage());
AfxMessageBox(strError);
}
m_pRecordset->Close();
m_pRecordset=NULL;
break;
case 2:
strSQL3.Format("select b from 需求和比较对象关系表4 where ID='%s' \
",\
cindex2);
if(!OpenRecordSet(m_pRecordset,strSQL3))
{
AfxMessageBox("没有成功打开数据表");
return;
}
a.Format("%d",m_xishu);
//上述准备完毕,下面开始插入内容
try
{
m_pRecordset->PutCollect("b",_variant_t(a));
//更新数据库
m_pRecordset->Update();
}
catch(_com_error e)
{
CString strError;
strError.Format("警告: 插入信息时发生异常。 错误信息: %s",\
e.ErrorMessage());
AfxMessageBox(strError);
}
m_pRecordset->Close();
m_pRecordset=NULL;
break;
case 3:
strSQL3.Format("select c from 需求和比较对象关系表4 where ID='%s' \
",\
cindex2);
if(!OpenRecordSet(m_pRecordset,strSQL3))
{
AfxMessageBox("没有成功打开数据表");
return;
}
a.Format("%d",m_xishu);
//上述准备完毕,下面开始插入内容
try
{
m_pRecordset->PutCollect("c",_variant_t(a));
//更新数据库
m_pRecordset->Update();
}
catch(_com_error e)
{
CString strError;
strError.Format("警告: 插入信息时发生异常。 错误信息: %s",\
e.ErrorMessage());
AfxMessageBox(strError);
}
m_pRecordset->Close();
m_pRecordset=NULL;
break;
case 4:
strSQL3.Format("select d from 需求和比较对象关系表4 where ID='%s' \
",\
cindex2);
if(!OpenRecordSet(m_pRecordset,strSQL3))
{
AfxMessageBox("没有成功打开数据表");
return;
}
a.Format("%d",m_xishu);
//上述准备完毕,下面开始插入内容
try
{
m_pRecordset->PutCollect("d",_variant_t(a));
//更新数据库
m_pRecordset->Update();
}
catch(_com_error e)
{
CString strError;
strError.Format("警告: 插入信息时发生异常。 错误信息: %s",\
e.ErrorMessage());
AfxMessageBox(strError);
}
m_pRecordset->Close();
m_pRecordset=NULL;
break;
case 5:
strSQL3.Format("select e from 需求和比较对象关系表4 where ID='%s' \
",\
cindex2);
if(!OpenRecordSet(m_pRecordset,strSQL3))
{
AfxMessageBox("没有成功打开数据表");
return;
}
a.Format("%d",m_xishu);
//上述准备完毕,下面开始插入内容
try
{
m_pRecordset->PutCollect("e",_variant_t(a));
//更新数据库
m_pRecordset->Update();
}
catch(_com_error e)
{
CString strError;
strError.Format("警告: 插入信息时发生异常。 错误信息: %s",\
e.ErrorMessage());
AfxMessageBox(strError);
}
m_pRecordset->Close();
m_pRecordset=NULL;
break;
case 6:
strSQL3.Format("select f from 需求和比较对象关系表4 where ID='%s' \
",\
cindex2);
if(!OpenRecordSet(m_pRecordset,strSQL3))
{
AfxMessageBox("没有成功打开数据表");
return;
}
a.Format("%d",m_xishu);
//上述准备完毕,下面开始插入内容
try
{
m_pRecordset->PutCollect("f",_variant_t(a));
//更新数据库
m_pRecordset->Update();
}
catch(_com_error e)
{
CString strError;
strError.Format("警告: 插入信息时发生异常。 错误信息: %s",\
e.ErrorMessage());
AfxMessageBox(strError);
}
m_pRecordset->Close();
m_pRecordset=NULL;
break;
case 7:
strSQL3.Format("select g from 需求和比较对象关系表4 where ID='%s' \
",\
cindex2);
if(!OpenRecordSet(m_pRecordset,strSQL3))
{
AfxMessageBox("没有成功打开数据表");
return;
}
a.Format("%d",m_xishu);
//上述准备完毕,下面开始插入内容
try
{
m_pRecordset->PutCollect("g",_variant_t(a));
//更新数据库
m_pRecordset->Update();
}
catch(_com_error e)
{
CString strError;
strError.Format("警告: 插入信息时发生异常。 错误信息: %s",\
e.ErrorMessage());
AfxMessageBox(strError);
}
m_pRecordset->Close();
m_pRecordset=NULL;
break;
case 8:
strSQL3.Format("select h from 需求和比较对象关系表4 where ID='%s' \
",\
cindex2);
if(!OpenRecordSet(m_pRecordset,strSQL3))
{
AfxMessageBox("没有成功打开数据表");
return;
}
a.Format("%d",m_xishu);
//上述准备完毕,下面开始插入内容
try
{
m_pRecordset->PutCollect("h",_variant_t(a));
//更新数据库
m_pRecordset->Update();
}
catch(_com_error e)
{
CString strError;
strError.Format("警告: 插入信息时发生异常。 错误信息: %s",\
e.ErrorMessage());
AfxMessageBox(strError);
}
m_pRecordset->Close();
m_pRecordset=NULL;
break;
case 9:
strSQL3.Format("select i from 需求和比较对象关系表4 where ID='%s' \
",\
cindex2);
if(!OpenRecordSet(m_pRecordset,strSQL3))
{
AfxMessageBox("没有成功打开数据表");
return;
}
a.Format("%d",m_xishu);
//上述准备完毕,下面开始插入内容
try
{
m_pRecordset->PutCollect("i",_variant_t(a));
//更新数据库
m_pRecordset->Update();
}
catch(_com_error e)
{
CString strError;
strError.Format("警告: 插入信息时发生异常。 错误信息: %s",\
e.ErrorMessage());
AfxMessageBox(strError);
}
m_pRecordset->Close();
m_pRecordset=NULL;
break;
case 10:
strSQL3.Format("select j from 需求和比较对象关系表4 where ID='%s' \
",\
cindex2);
if(!OpenRecordSet(m_pRecordset,strSQL3))
{
AfxMessageBox("没有成功打开数据表");
return;
}
a.Format("%d",m_xishu);
//上述准备完毕,下面开始插入内容
try
{
m_pRecordset->PutCollect("j",_variant_t(a));
//更新数据库
m_pRecordset->Update();
}
catch(_com_error e)
{
CString strError;
strError.Format("警告: 插入信息时发生异常。 错误信息: %s",\
e.ErrorMessage());
AfxMessageBox(strError);
}
m_pRecordset->Close();
m_pRecordset=NULL;
break;
default:break;
} //打开记录集 选择表名
}
BEGIN_EVENTSINK_MAP(CxuqiuVSduixiang4, CDialog)
//{{AFX_EVENTSINK_MAP(CxuqiuVSduixiang4)
ON_EVENT(CxuqiuVSduixiang4, IDC_DATALIST1, -600 /* Click */, OnClickDatalist1, VTS_NONE)
ON_EVENT(CxuqiuVSduixiang4, IDC_DATALIST2, -600 /* Click */, OnClickDatalist2, VTS_NONE)
//}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()
void CxuqiuVSduixiang4::OnClickDatalist1()
{
UpdateData(true);//更新编辑框,并且将当前编辑框的数值赋给m_xishu
int index1=0,index2=0;
CString term1;
CString term2;
term1=m_list1.GetText();
term2=m_list2.GetText();
CString strSQL1;
strSQL1.Format("select * from 工程措施3 where 工程措施='%s' \
",\
term1
);
//打开记录集 选择表名
if(!OpenRecordSet(m_pRecordset,strSQL1))
{
AfxMessageBox("没有成功打开数据表");
return;
}
CString cindex1=VariantToCString(m_pRecordset->GetCollect("ID"));
index1=atoi(cindex1);
//关闭
m_pRecordset->Close();
m_pRecordset=NULL;
if(term2!="")
{
CString strSQL2;
strSQL2.Format("select * from 比较对象 where 比较对象='%s' \
",\
term2
);
//打开记录集 选择表名
if(!OpenRecordSet(m_pRecordset,strSQL2))
{
AfxMessageBox("没有成功打开数据表");
return;
}
CString cindex2=VariantToCString(m_pRecordset->GetCollect("ID"));
index2=atoi(cindex2);
//关闭
m_pRecordset->Close();
m_pRecordset=NULL;
// m_xishu=index1;
//UpdateData(false); //更新编辑框,但不将当前编辑框的数值赋给m_xishu
// AfxMessageBox(term1 + " "+ term2+" " + cindex1+ " " +cindex2);
CString strSQL3;
CString a;
switch(index1){
case 1:
strSQL3.Format("select a from 需求和比较对象关系表4 where ID='%s' \
",\
cindex2);
if(!OpenRecordSet(m_pRecordset,strSQL3))
{
AfxMessageBox("没有成功打开数据表");
return;
}
//a.Format("%d",m_xishu);
//上述准备完毕,下面开始插入内容
try
{
// m_pRecordset->PutCollect("a",_variant_t(a));
m_xishu=atoi(VariantToCString(m_pRecordset->GetCollect("a")));
UpdateData(false);
//更新数据库
m_pRecordset->Update();
}
catch(_com_error e)
{
CString strError;
strError.Format("警告: 插入信息时发生异常。 错误信息: %s",\
e.ErrorMessage());
AfxMessageBox(strError);
}
m_pRecordset->Close();
m_pRecordset=NULL;
break;
case 2:
strSQL3.Format("select b from 需求和比较对象关系表4 where ID='%s' \
",\
cindex2);
if(!OpenRecordSet(m_pRecordset,strSQL3))
{
AfxMessageBox("没有成功打开数据表");
return;
}
//上述准备完毕,下面开始插入内容
try
{
m_xishu=atoi(VariantToCString(m_pRecordset->GetCollect("b")));
UpdateData(false);
//更新数据库
m_pRecordset->Update();
}
catch(_com_error e)
{
CString strError;
strError.Format("警告: 插入信息时发生异常。 错误信息: %s",\
e.ErrorMessage());
AfxMessageBox(strError);
}
m_pRecordset->Close();
m_pRecordset=NULL;
break;
case 3:
strSQL3.Format("select c from 需求和比较对象关系表4 where ID='%s' \
",\
cindex2);
if(!OpenRecordSet(m_pRecordset,strSQL3))
{
AfxMessageBox("没有成功打开数据表");
return;
}
//上述准备完毕,下面开始插入内容
try
{
m_xishu=atoi(VariantToCString(m_pRecordset->GetCollect("c")));
UpdateData(false);
//更新数据库
m_pRecordset->Update();
}
catch(_com_error e)
{
CString strError;
strError.Format("警告: 插入信息时发生异常。 错误信息: %s",\
e.ErrorMessage());
AfxMessageBox(strError);
}
m_pRecordset->Close();
m_pRecordset=NULL;
break;
case 4:
strSQL3.Format("select d from 需求和比较对象关系表4 where ID='%s' \
",\
cindex2);
if(!OpenRecordSet(m_pRecordset,strSQL3))
{
AfxMessageBox("没有成功打开数据表");
return;
}
//上述准备完毕,下面开始插入内容
try
{
m_xishu=atoi(VariantToCString(m_pRecordset->GetCollect("d")));
UpdateData(false);
//更新数据库
m_pRecordset->Update();
}
catch(_com_error e)
{
CString strError;
strError.Format("警告: 插入信息时发生异常。 错误信息: %s",\
e.ErrorMessage());
AfxMessageBox(strError);
}
m_pRecordset->Close();
m_pRecordset=NULL;
break;
case 5:
strSQL3.Format("select e from 需求和比较对象关系表4 where ID='%s' \
",\
cindex2);
if(!OpenRecordSet(m_pRecordset,strSQL3))
{
AfxMessageBox("没有成功打开数据表");
return;
}
//上述准备完毕,下面开始插入内容
try
{
m_xishu=atoi(VariantToCString(m_pRecordset->GetCollect("e")));
UpdateData(false);
//更新数据库
m_pRecordset->Update();
}
catch(_com_error e)
{
CString strError;
strError.Format("警告: 插入信息时发生异常。 错误信息: %s",\
e.ErrorMessage());
AfxMessageBox(strError);
}
m_pRecordset->Close();
m_pRecordset=NULL;
break;
case 6:
strSQL3.Format("select f from 需求和比较对象关系表4 where ID='%s' \
",\
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -