📄 query.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Query.h"
#include "PostMain.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TQueryForm *QueryForm;
static String Sql;
//---------------------------------------------------------------------------
__fastcall TQueryForm::TQueryForm(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TQueryForm::StringGrid1DrawCell(TObject *Sender, int ACol,
int ARow, TRect &Rect, TGridDrawState State)
{
TStringGrid * SG = dynamic_cast<TStringGrid *>(Sender);
if(SG){
try
{
if(ARow>=SG->FixedRows && ACol>=SG->FixedCols)
{
if(ARow%2 == 0)
{
SG->Canvas->Brush->Color=(TColor) 0x00E6FADC;
//0x00FECFFD;
//0x00E6FADC; 0x00FCE2EE
}
else
{
SG->Canvas->Brush->Color=(TColor) 0x00FBEFD5;
//0x00FBEFD5;
}
}
else{
SG->Canvas->Font->Color = clBlack;
SG->Canvas->Brush->Color=(TColor)0x00DDDDDD;
}
SG->Canvas->FillRect(Rect);
DrawText(SG->Canvas->Handle, SG->Cells[ACol][ARow].c_str(), -1, (RECT*)&Rect, DT_SINGLELINE | DT_VCENTER | DT_CENTER);
}
catch(Exception &exception)
{
Application->ShowException(&exception);
return ;
}
}
}
//---------------------------------------------------------------------------
void __fastcall TQueryForm::SpeedButton1Click(TObject *Sender)
{
String Sql;
if(QueryTag==9)
Sql="select * from Newspaper where (jianpin like '" +
LabeledEdit5->Text + "%' Or name like '" + LabeledEdit5->Text + "%' ) and code like '"
+ "_" + LabeledEdit6->Text + "%'";
else
Sql="select * from orderform where client like '" + LabeledEdit1->Text + "%'";
StringGrid1->RowCount=2;
try{
if ( MainForm->ExecuteSQL( Sql, 1 ) > 0 ){
MainForm->ADOQuery1->DisableControls();
int i=1;
while(! MainForm->ADOQuery1->Eof ){
for(int j=0;j<=MainForm->ADOQuery1->FieldCount-1;j++){
StringGrid1->Cells[j][i]=MainForm->ADOQuery1->Fields->Fields[j]->AsString.Trim();
}
i++;
StringGrid1->RowCount++;
MainForm->ADOQuery1->Next();
}
MainForm->ADOQuery1->EnableControls();
}
}
catch (Exception &exception)
{
Application->ShowException(&exception);
return ;
}
for(int i=0;i<StringGrid1->ColCount;i++)
StringGrid1->Cells[i][StringGrid1->RowCount-1]="";
}
//---------------------------------------------------------------------------
void __fastcall TQueryForm::FormShow(TObject *Sender)
{
if(QueryTag==9){
StringGrid1->ColCount=6;
StringGrid1->Cells[1][0]="报刊编号";
StringGrid1->Cells[0][0]="报刊名称";
StringGrid1->Cells[5][0]="发行期";
StringGrid1->Cells[2][0]="单 价";
StringGrid1->Cells[3][0]="简拼码";
StringGrid1->Cells[4][0]="杂志社名";
Caption=MainForm->N9->Caption;
LabeledEdit1->Visible=false;
LabeledEdit5->Visible=true;
LabeledEdit6->Visible=true;
}
else if(QueryTag==12){
StringGrid1->ColCount=14;
StringGrid1->Cells[0][0]="序 号";
StringGrid1->Cells[1][0]="订阅人";
StringGrid1->Cells[2][0]="地 址";
StringGrid1->Cells[3][0]="邮 编";
StringGrid1->Cells[4][0]="电 话";
StringGrid1->Cells[5][0]="订阅日期";
StringGrid1->Cells[6][0]="报刊名称";
StringGrid1->Cells[7][0]="报刊编号";
StringGrid1->Cells[8][0]="发行期";
StringGrid1->Cells[9][0]="单 价";
StringGrid1->Cells[10][0]="份 数";
StringGrid1->Cells[11][0]="起始月";
StringGrid1->Cells[12][0]="期 限";
StringGrid1->Cells[13][0]="金 额";
Caption=MainForm->N9->Caption;
LabeledEdit1->Visible=true;
LabeledEdit5->Visible=false;
LabeledEdit6->Visible=false;
}
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -