📄 cliceunit.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "CliceUnit.h"
#include "DMUnit.h"
#include "MainUnit.h"
#include "CountUnit.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "RzPanel"
#pragma link "RzTabs"
#pragma link "Wwdatsrc"
#pragma link "RzDBLbl"
#pragma link "RzLabel"
#pragma link "RzButton"
#pragma link "RzRadChk"
#pragma link "RzDBNav"
#pragma link "RzBmpBtn"
#pragma link "RzEdit"
#pragma resource "*.dfm"
Tfrm_cliceQuestion *frm_cliceQuestion;
AnsiString acq,acf,ard;
//---------------------------------------------------------------------------
__fastcall Tfrm_cliceQuestion::Tfrm_cliceQuestion(TComponent* Owner)
: TForm(Owner)
{
acq = frm_client->cq;
acf = frm_client->cf;
ard = frm_client->rd;
//打开答库卡
if(!tbl_Question) tbl_Question->Active = false;
tbl_Question->Connection = DM->conc;
tbl_Question->TableName = acq;
tbl_Question->Active = true;
//打开题库
rzpgcntrl1->ActivePageIndex = 0;
rztbshtTabSheet1->TabVisible = false;
rztbshtTabSheet2->TabVisible = false;
rztbshtTabSheet3->TabVisible = false;
qry_Question->Open();
readques();
}
//---------------------------------------------------------------------------
void __fastcall Tfrm_cliceQuestion::btn1Click(TObject *Sender)
{
rzpgcntrl1->ActivePageIndex = 1;
btn1->Visible = false;
btn2->Visible = true;
btn3->Visible = true;
btn4->Visible = true;
}
//---------------------------------------------------------------------------
void __fastcall Tfrm_cliceQuestion::btn2Click(TObject *Sender)
{
AnsiString tid;
if(ifrb())
{
TLocateOptions Opts;
Opts.Clear();
Opts << loPartialKey;
Variant locvalues ;
locvalues = Variant(lblIDNum->Caption.Trim());
if(tbl_Question->Locate("IDNum",locvalues,Opts))
{
tbl_Question->Edit();
if(rba->Checked)
tbl_Question->FieldByName("RA")->AsInteger = qry_Question->FieldByName("RA")->AsInteger;
else if(rbb->Checked)
tbl_Question->FieldByName("RB")->AsInteger = qry_Question->FieldByName("RB")->AsInteger;
else
tbl_Question->FieldByName("RC")->AsInteger = qry_Question->FieldByName("RC")->AsInteger;
tbl_Question->Post();
qry_Question->Next();
clearra() ;
readques();
}
if (lblIDNum->Caption == "187")
{
btn2->Enabled = false;
btn3->Enabled = false;
btn4->Enabled = true;
rzpgcntrl1->ActivePageIndex = 2;
}
}
else
{
Application->MessageBox("请选择符全自己性格类型的答案~~~",Application->Title.c_str(), MB_OK + MB_ICONSTOP + MB_TOPMOST);
return;
}
}
//---------------------------------------------------------------------------
void __fastcall Tfrm_cliceQuestion::btn3Click(TObject *Sender)
{
qry_Question->Prior();
tbl_Question->Prior();
tbl_Question->Edit();
tbl_Question->FieldByName("RA")->AsInteger = 0;
tbl_Question->FieldByName("RB")->AsInteger = 0;
tbl_Question->FieldByName("RC")->AsInteger = 0;
tbl_Question->Post();
}
//---------------------------------------------------------------------------
void Tfrm_cliceQuestion::clearra()
{
//TODO: Add your source code here
rba->Checked = false;
rbb->Checked = false;
rbc->Checked = false;
}
bool Tfrm_cliceQuestion::ifrb()
{
//TODO: Add your source code here
if(rba->Checked || rbb->Checked || rbc->Checked)
return true;
else
return false;
}
void __fastcall Tfrm_cliceQuestion::btn4Click(TObject *Sender)
{
AnsiString sqltxt;
frm_count->Show();
frm_count->Update();
tbl_Question->First();
frm_count->upPercent();
for(int i = 0;i<= tbl_Question->RecordCount;i++)
{
frm_count->upPercent();
tbl_Question->Edit();
tbl_Question->FieldByName("RNum")->AsInteger = tbl_Question->FieldByName("RA")->AsInteger + tbl_Question->FieldByName("RB")->AsInteger + tbl_Question->FieldByName("RC")->AsInteger;
tbl_Question->Post();
tbl_Question->Next();
}
creatrep(); //生成报告
frm_count->upPercent();
sqltxt = "update Client set Client.bEnd = 1 Where RID = \"" + ard +"\"";
frm_count->upPercent();
// ShowMessage(sqltxt);
frm_count->upPercent();
DM->qry_public->Close();
frm_count->upPercent();
DM->qry_public->Connection = DM->conn;
frm_count->upPercent();
DM->qry_public->SQL->Clear();
frm_count->upPercent();
DM->qry_public->SQL->Add(sqltxt);
frm_count->upPercent();
DM->qry_public->ExecSQL();
frm_count->upPercent();
frm_count->Hide();
this->Close();
}
//---------------------------------------------------------------------------
void __fastcall Tfrm_cliceQuestion::btn2KeyDown(TObject *Sender, WORD &Key,
TShiftState Shift)
{
if((Key == 'a') ||(Key == 'A'))
rba->Checked = true;
if ((Key == 'b') || (Key == 'B'))
rbb->Checked = true;
if ((Key == 'c') || (Key == 'C'))
rbc->Checked = true;
}
//---------------------------------------------------------------------------
void Tfrm_cliceQuestion::readques()
{
//TODO: Add your source code here
rba->Caption = "A、" + RzDBLabel2->Caption;
rbb->Caption = "B、" + RzDBLabel3->Caption;
rbc->Caption = "C、" + RzDBLabel4->Caption;
}
void Tfrm_cliceQuestion::creatrep()
{
//TODO: 生成测试评测报告
AnsiString tSql,ca;
TADOQuery *tQryings = new TADOQuery(this);
TADOQuery *tQry = new TADOQuery(this);
frm_count->upPercent();
try
{
tSql = "select * from " + acf;
frm_count->upPercent();
tQryings->Connection = DM->conc;
frm_count->upPercent();
tQryings->Close();
frm_count->upPercent();
tQryings->SQL->Clear();
frm_count->upPercent();
tQryings->SQL->Add(tSql);
frm_count->upPercent();
tQryings->Open();
frm_count->upPercent();
tQry->Connection = DM->conc;
frm_count->upPercent();
tQry->Close();
frm_count->upPercent();
tQryings->First();
while(!tQryings->Eof)
{
frm_count->upPercent();
tSql = "select SUM(RNum) as cs from " + acq + " where Factor = \"" + tQryings->FieldByName("Factor")->AsString + "\"";
tQry->SQL->Clear();
tQry->SQL->Add(tSql);
tQry->Open();
tQryings->Edit();
tQryings->FieldByName("原始分")->AsInteger = tQry->FieldByName("cs")->AsInteger;
tQryings->Post();
tQryings->Next();
}
}
catch(...)
{
Application->MessageBox("系统错误,生成评测报告错误,请联系管理员。",
Application->Title.c_str(), MB_OK + MB_ICONSTOP + MB_TOPMOST);
}
delete tQryings;
delete tQry;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -