📄 sspquery.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#include "SspQuery.h"
//---------------------------------------------------------------------------
#pragma hdrstop
#pragma package(smart_init)
#pragma link "QueryBaseForm"
#pragma link "SDGrid"
#pragma resource "*.dfm"
TfrmSspQuery *frmSspQuery;
//---------------------------------------------------------------------------
__fastcall TfrmSspQuery::TfrmSspQuery(TComponent* Owner)
: TQueryBaseForm(Owner)
{
sgSspQuery->RowCount=3;
InitGridControl();
}
//---------------------------------------------------------------------------
void __fastcall TfrmSspQuery::InitGridControl()
{
sgSspQuery->Cells[0][0]="销售员"; sgSspQuery->Cells[0][1]="销售员";
sgSspQuery->Cells[1][0]="年度"; sgSspQuery->Cells[1][1]="年度";
sgSspQuery->Cells[2][0]="一月"; sgSspQuery->Cells[2][1]="计划金额";
sgSspQuery->Cells[3][0]="一月"; sgSspQuery->Cells[3][1]="完成金额";
sgSspQuery->Cells[4][0]="二月"; sgSspQuery->Cells[4][1]="计划金额";
sgSspQuery->Cells[5][0]="二月"; sgSspQuery->Cells[5][1]="完成金额";
sgSspQuery->Cells[6][0]="三月"; sgSspQuery->Cells[6][1]="计划金额";
sgSspQuery->Cells[7][0]="三月"; sgSspQuery->Cells[7][1]="完成金额";
sgSspQuery->Cells[8][0]="四月"; sgSspQuery->Cells[8][1]="计划金额";
sgSspQuery->Cells[9][0]="四月"; sgSspQuery->Cells[9][1]="完成金额";
sgSspQuery->Cells[10][0]="五月"; sgSspQuery->Cells[10][1]="计划金额";
sgSspQuery->Cells[11][0]="五月"; sgSspQuery->Cells[11][1]="完成金额";
sgSspQuery->Cells[12][0]="六月"; sgSspQuery->Cells[12][1]="计划金额";
sgSspQuery->Cells[13][0]="六月"; sgSspQuery->Cells[13][1]="完成金额";
sgSspQuery->Cells[14][0]="七月"; sgSspQuery->Cells[14][1]="计划金额";
sgSspQuery->Cells[15][0]="七月"; sgSspQuery->Cells[15][1]="完成金额";
sgSspQuery->Cells[16][0]="八月"; sgSspQuery->Cells[16][1]="计划金额";
sgSspQuery->Cells[17][0]="八月"; sgSspQuery->Cells[17][1]="完成金额";
sgSspQuery->Cells[18][0]="九月"; sgSspQuery->Cells[18][1]="计划金额";
sgSspQuery->Cells[19][0]="九月"; sgSspQuery->Cells[19][1]="完成金额";
sgSspQuery->Cells[20][0]="十月"; sgSspQuery->Cells[20][1]="计划金额";
sgSspQuery->Cells[21][0]="十月"; sgSspQuery->Cells[21][1]="完成金额";
sgSspQuery->Cells[22][0]="十一月"; sgSspQuery->Cells[22][1]="计划金额";
sgSspQuery->Cells[23][0]="十一月"; sgSspQuery->Cells[23][1]="完成金额";
sgSspQuery->Cells[24][0]="十二月"; sgSspQuery->Cells[24][1]="计划金额";
sgSspQuery->Cells[25][0]="十二月"; sgSspQuery->Cells[25][1]="完成金额";
}
//---------------------------------------------------------------------------
void __fastcall TfrmSspQuery::tbQueryClick(TObject *Sender)
{
if(!ShowQueryWindow())
return;
try
{
StartWaitForm("正在查询,请稍候...");
FillGridWithData();
}
__finally
{
EndWaitForm();
}
}
//---------------------------------------------------------------------------
bool __fastcall TfrmSspQuery::ShowQueryWindow()
{
TfrmQuForm *FQuery=new TfrmQuForm(this,this->Name);
FQuery->ShowModal();
if(FQuery->CancelQuery)
return false;
FilterStr=FQuery->CreateSqlString;
delete FQuery;
return true;
}
//---------------------------------------------------------------------------
void __fastcall TfrmSspQuery::ClearControl(bool BringToNext)
{
return;
}
//---------------------------------------------------------------------------
void __fastcall TfrmSspQuery::GetDataFromComObject()
{
return;
}
//---------------------------------------------------------------------------
void __fastcall TfrmSspQuery::WaitUserInput()
{
return;
}
//---------------------------------------------------------------------------
void __fastcall TfrmSspQuery::RefreshGridData(int mAction)
{
return;
}
//---------------------------------------------------------------------------
void __fastcall TfrmSspQuery::DisplayBill()
{
return;
}
//---------------------------------------------------------------------------
void __fastcall TfrmSspQuery::GetBill(AnsiString BillID)
{
return;
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmSspQuery::GetQueryStr()
{
AnsiString Selstr,Fromstr,Wherestr,Orderstr;
Selstr =" select * ";
Fromstr=" from SDVW_SSP ";
if(FilterStr!="")
Wherestr=" where "+ FilterStr;
Orderstr=" Order by SspSaler,SspYear";
sSQL=Selstr+Fromstr+Wherestr+Orderstr;
return(sSQL);
}
//---------------------------------------------------------------------------
void __fastcall TfrmSspQuery::FillGridWithData()
{
AnsiString sSql;
AnsiString ItemStr;
TComResultSet *RsQuery;
sSql=GetQueryStr();
if(sSql=="")
return;
sgSspQuery->RowCount=2;
RsQuery=NewResultSet();
RsQuery->Open(WideString(sSql),WideString(""));
RsQuery->MoveFirst();
while(RsQuery->Eof == 0)
{
ItemStr=RsQuery->FieldByName("SspSaler")+
"\t"+RsQuery->FieldByName("SspYear")+
"\t"+RsQuery->FieldByName("PAmt1")+
"\t"+RsQuery->FieldByName("RAmt1")+
"\t"+RsQuery->FieldByName("PAmt2")+
"\t"+RsQuery->FieldByName("RAmt2")+
"\t"+RsQuery->FieldByName("PAmt3")+
"\t"+RsQuery->FieldByName("RAmt3")+
"\t"+RsQuery->FieldByName("PAmt4")+
"\t"+RsQuery->FieldByName("RAmt4")+
"\t"+RsQuery->FieldByName("PAmt5")+
"\t"+RsQuery->FieldByName("RAmt5")+
"\t"+RsQuery->FieldByName("PAmt6")+
"\t"+RsQuery->FieldByName("RAmt6")+
"\t"+RsQuery->FieldByName("PAmt7")+
"\t"+RsQuery->FieldByName("RAmt7")+
"\t"+RsQuery->FieldByName("PAmt8")+
"\t"+RsQuery->FieldByName("RAmt8")+
"\t"+RsQuery->FieldByName("PAmt9")+
"\t"+RsQuery->FieldByName("RAmt9")+
"\t"+RsQuery->FieldByName("PAmt10")+
"\t"+RsQuery->FieldByName("RAmt10")+
"\t"+RsQuery->FieldByName("PAmt11")+
"\t"+RsQuery->FieldByName("RAmt11")+
"\t"+RsQuery->FieldByName("PAmt12")+
"\t"+RsQuery->FieldByName("RAmt12");
sgSspQuery->AddItem(ItemStr);
RsQuery->MoveNext();
}
RsQuery->Close();
delete RsQuery;
}
//---------------------------------------------------------------------------
void __fastcall TfrmSspQuery::muFirstClick(TObject *Sender)
{
if(sgSspQuery->RowCount > 2)
sgSspQuery->Row=2;
}
//---------------------------------------------------------------------------
void __fastcall TfrmSspQuery::muPreviousClick(TObject *Sender)
{
if(sgSspQuery->RowCount > 1 && sgSspQuery->Row > 1)
sgSspQuery->Row=sgSspQuery->Row-1;
}
//---------------------------------------------------------------------------
void __fastcall TfrmSspQuery::muNextClick(TObject *Sender)
{
if(sgSspQuery->RowCount > 1 && sgSspQuery->Row < sgSspQuery->RowCount-1)
sgSspQuery->Row=sgSspQuery->Row+1;
}
//---------------------------------------------------------------------------
void __fastcall TfrmSspQuery::muLastClick(TObject *Sender)
{
if(sgSspQuery->RowCount > 1)
sgSspQuery->Row=sgSspQuery->RowCount-1;
}
//---------------------------------------------------------------------------
void __fastcall TfrmSspQuery::tbRefreshClick(TObject *Sender)
{
if(sSQL=="")
return;
FillGridWithData();
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -