qu_apan.cpp
来自「一个以前收集的基于C/S架构的ERP客户端源代码」· C++ 代码 · 共 400 行
CPP
400 行
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Qu_ApAn.h"
#include "ApAnd.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "QueryBaseForm"
#pragma link "SDGrid"
#pragma link "KSAdvReport"
#pragma resource "*.dfm"
TfrmQu_ApAn *frmQu_ApAn;
//---------------------------------------------------------------------------
__fastcall TfrmQu_ApAn::TfrmQu_ApAn(TComponent* Owner, HWND chWnd, AnsiString MidCode,AnsiString WhereStr)
: TQueryBaseForm(Owner,chWnd,MidCode,WhereStr)
{
m_SQL=""; //查询语句
RsQuery=new TComResultSet(Handle,g_ClientHandle);
sChart->Visible=false;
sChart->AllowZoom=false;
QueryGrid=sgApAn;
InitGrid();
}
//---------------------------------------------------------------------------
void __fastcall TfrmQu_ApAn::ClearControl(bool BringToNext)
{
return;
}
//---------------------------------------------------------------------------
void __fastcall TfrmQu_ApAn::GetDataFromComObject()
{
return;
}
//---------------------------------------------------------------------------
void __fastcall TfrmQu_ApAn::WaitUserInput()
{
return;
}
//---------------------------------------------------------------------------
void __fastcall TfrmQu_ApAn::RefreshGridData(int mAction)
{
return;
}
//---------------------------------------------------------------------------
void __fastcall TfrmQu_ApAn::DisplayBill()
{
return;
}
//---------------------------------------------------------------------------
void __fastcall TfrmQu_ApAn::GetBill(AnsiString BillID)
{
return;
}
//---------------------------------------------------------------------------
void __fastcall TfrmQu_ApAn::FillGridWithData()
{
AnsiString ItemStr="",ItemStr1="",m_FiStr="";
int i=2;
if(FilterStr=="")
m_FiStr="";
else
m_FiStr=" where "+FilterStr;
m_SQL=" select * from sdVW_ApAnu "+m_FiStr+" order by supply,agedays";
sgApAn->RowCount=1;
RsQuery->Close();
RsQuery->Open(m_SQL,"");
RsQuery->MoveFirst();
while( RsQuery->Eof == 0)
{
ItemStr=RsQuery->FieldByName("supplyName");
ItemStr1+="\t";
AnsiString Amt=RsQuery->FieldByName("disAmt");
ItemStr1+=AnsiString(DataCarry(Amt.ToDouble(),2,0));
i++;
if(i>=sgApAn->ColCount)
{
sgApAn->AddItem("\t"+ItemStr+ItemStr1);
ItemStr1="";
i=2;
}
RsQuery->MoveNext();
}
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
void __fastcall TfrmQu_ApAn::InitGrid()
{
TComResultSet *RsAge=new TComResultSet(Handle,g_ClientHandle);
AnsiString Sql;
int i=2;
try{
Sql="select APoAGENO ,APoAGEDAYS from sdApoAge order by APoAGEDAYS desc";
RsAge->Close();
RsAge->Open(Sql,"");
sgApAn->ColCount=RsAge->RecordCount+3;
i=2;
RsAge->MoveFirst();
sgApAn->Columns->Items[i]->ColumnWidth=50;
sgApAn->Columns->Items[i]->TitleString="过期"+RsAge->FieldByName("APoAGEDAYS")+"天以上";
i++;
while( RsAge->Eof == 0)
{
sgApAn->Columns->Items[i]->ColumnWidth=50;
sgApAn->Columns->Items[i]->TitleString="过期"+RsAge->FieldByName("APoAGEDAYS")+"天内";
i++;
RsAge->MoveNext();
}
Sql="select APUAGENO ,APUAGEDAYS from sdApuAge order by APUAGEDAYS ";
RsAge->Close();
RsAge->Open(Sql,"");
sgApAn->ColCount=sgApAn->ColCount+RsAge->RecordCount+1;
RsAge->MoveFirst();
while( RsAge->Eof == 0)
{
sgApAn->Columns->Items[i]->ColumnWidth=50;
sgApAn->Columns->Items[i]->TitleString="还有"+RsAge->FieldByName("APUAGEDAYS")+"天";
i++;
RsAge->MoveNext();
}
sgApAn->Columns->Items[i]->ColumnWidth=100;
sgApAn->Columns->Items[i]->TitleString="还有"+RsAge->FieldByName("APUAGEDAYS")+"天以上";
RsAge->Close();
}
__finally
{
delete RsAge;
}
}
void __fastcall TfrmQu_ApAn::tbQueryClick(TObject *Sender)
{
// if(!ShowQueryWindow())
// return;
try
{
StartWaitForm("正在查询,请稍候...");
FillGridWithData();
if(RsQuery->RecordCount>0)
sChart->Visible=true;
else
sChart->Visible=false;
spColClick(Sender);
}
__finally
{
EndWaitForm();
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmQu_ApAn::tbRefreshClick(TObject *Sender)
{
if(m_SQL!="")
FillGridWithData();
}
//---------------------------------------------------------------------------
void __fastcall TfrmQu_ApAn::sgApAnDblClick(TObject *Sender)
{
if(sgApAn->Row>0 &&sgApAn->Row<sgApAn->RowCount) //当前行无效
{
RsQuery->MoveFirst();
RsQuery->LocateByIndex((sgApAn->ColCount-3)*sgApAn->Row);
TfrmApAnd *m_ApAnd=new TfrmApAnd(this);
m_ApAnd->m_Supply=RsQuery->FieldByName("supply");
m_ApAnd->ShowModal();
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmQu_ApAn::FormClose(TObject *Sender,
TCloseAction &Action)
{
TQueryBaseForm::FormClose(Sender,Action);
RsQuery->Close();
delete RsQuery;
}
//---------------------------------------------------------------------------
void __fastcall TfrmQu_ApAn::muFirstClick(TObject *Sender)
{
if(sgApAn->RowCount > 1)
sgApAn->Row=1;
}
//---------------------------------------------------------------------------
void __fastcall TfrmQu_ApAn::muPreviousClick(TObject *Sender)
{
if( sgApAn->Row>1)
sgApAn->Row--;
}
//---------------------------------------------------------------------------
void __fastcall TfrmQu_ApAn::muNextClick(TObject *Sender)
{
if( sgApAn->Row < sgApAn->RowCount-1)
sgApAn->Row++;
}
//---------------------------------------------------------------------------
void __fastcall TfrmQu_ApAn::muLastClick(TObject *Sender)
{
if(sgApAn->RowCount > 1)
sgApAn->Row=sgApAn->RowCount-1;
}
//---------------------------------------------------------------------------
void __fastcall TfrmQu_ApAn::Draw(AnsiString type)
{
AnsiString m_Num;
double m_Num1=0;
if(sChart->SeriesCount()>0)
sChart->FreeAllSeries();
sChart->BackColor=clBtnFace;
sChart->View3D=true;
sChart->View3DOptions->Orthogonal=true;
sb3d->Position= sChart->Chart3DPercent;
if(type=="col")
{
Bar = new TBarSeries(this);
Bar->Marks->Style=smsValue;
Bar->ColorEachPoint=true;
Bar->BarStyle=bsRectGradient;
sChart->LeftAxis->Grid->Visible=chGr->Checked;
sChart->BottomAxis->Grid->Visible=chGr->Checked;
sChart->AddSeries(Bar);
for(int i=2;i<sgApAn->ColCount;i++)
{
for(int j=1;j<sgApAn->RowCount;j++)
{
m_Num=sgApAn->TextMatrix[j][i];
m_Num1=m_Num1+m_Num.ToDouble();
}
if(m_Num1!=0)
Bar->AddBar(m_Num1,sgApAn->Columns->Items[i]->TitleString,clTeeColor);
m_Num1=0;
}
}
if(type=="Cir")
{
Pie = new TPieSeries(this);
sChart->AddSeries(Pie);
for(int i=2;i<sgApAn->ColCount;i++)
{
for(int j=1;j<sgApAn->RowCount;j++)
{
m_Num=sgApAn->TextMatrix[j][i];
m_Num1=m_Num1+m_Num.ToDouble();
}
if(m_Num1!=0)
Pie->AddPie(m_Num1,sgApAn->Columns->Items[i]->TitleString,clTeeColor);
m_Num1=0;
}
}
if(sChart->GetMaxValuesCount()<=1)
SetToolState(false);
}
//---------------------------------------------------------------------------
void __fastcall TfrmQu_ApAn::spColClick(TObject *Sender)
{
SetToolState(true);
Draw("col");
}
//---------------------------------------------------------------------------
void __fastcall TfrmQu_ApAn::spPieClick(TObject *Sender)
{
SetToolState(false);
Draw("Cir");
}
//---------------------------------------------------------------------------
void __fastcall TfrmQu_ApAn::ch3DMouseUp(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{
if(ch3D->Checked)
sChart->View3D=true;
else
sChart->View3D=false;
}
//---------------------------------------------------------------------------
void __fastcall TfrmQu_ApAn::chGrMouseUp(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{
if(chGr->Checked)
{
sChart->LeftAxis->Grid->Visible=true;
sChart->BottomAxis->Grid->Visible=true;
}
else
{
sChart->LeftAxis->Grid->Visible=false;
sChart->BottomAxis->Grid->Visible=false;
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmQu_ApAn::sb3dChange(TObject *Sender)
{
if(sb3d->Position==0)
return ;
sChart->Chart3DPercent=sb3d->Position;
}
//---------------------------------------------------------------------------
void __fastcall TfrmQu_ApAn::Zoom(TChart *ch ,double percent)
{
TRect r=ch->ChartRect;
r.Left=r.Left+percent;
r.Right=r.Right-percent;
r.Top=r.Top+percent;
ch->ZoomRect(r);
}
//---------------------------------------------------------------------------
void __fastcall TfrmQu_ApAn::spOutClick(TObject *Sender)
{
Zoom(sChart,5);
spUd->Enabled=true;
}
//---------------------------------------------------------------------------
void __fastcall TfrmQu_ApAn::spInClick(TObject *Sender)
{
Zoom(sChart,-5);
spUd->Enabled=true;
}
//---------------------------------------------------------------------------
void __fastcall TfrmQu_ApAn::XYScroll(TChart *Ch ,AnsiString xy,const double Percent)
{
TRect r=Ch->ChartRect;
if(xy=="x")
{
r.Left=r.Left-Percent;
r.Right=r.Right-Percent;
}
if(xy=="y")
{
r.Top=r.Top-Percent;
r.Bottom=r.Bottom-Percent;
}
Ch->ZoomRect(r);
}
//---------------------------------------------------------------------------
void __fastcall TfrmQu_ApAn::spLeClick(TObject *Sender)
{
XYScroll(sChart,"x",-5);
spUd->Enabled=true;
}
//---------------------------------------------------------------------------
void __fastcall TfrmQu_ApAn::spRiClick(TObject *Sender)
{
XYScroll(sChart,"x",5);
spUd->Enabled=true;
}
//---------------------------------------------------------------------------
void __fastcall TfrmQu_ApAn::spUpClick(TObject *Sender)
{
XYScroll(sChart,"y",-5);
spUd->Enabled=true;
}
//---------------------------------------------------------------------------
void __fastcall TfrmQu_ApAn::spDoClick(TObject *Sender)
{
XYScroll(sChart,"y",5);
spUd->Enabled=true;
}
//---------------------------------------------------------------------------
void __fastcall TfrmQu_ApAn::spUdClick(TObject *Sender)
{
sChart->UndoZoom();
spUd->Enabled=false;
}
//---------------------------------------------------------------------------
void __fastcall TfrmQu_ApAn::SetToolState(bool Flag)
{
if(Flag)
{
chGr->Enabled=true;
spOut->Enabled=true;
spIn->Enabled=true;
spLe->Enabled=true;
spRi->Enabled=true;
spUp->Enabled=true;
spDo->Enabled=true;
}
else
{
chGr->Enabled=false;
spOut->Enabled=false;
spIn->Enabled=false;
spLe->Enabled=false;
spRi->Enabled=false;
spUp->Enabled=false;
spDo->Enabled=false;
spUd->Enabled=false;
}
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?