glbm_project.cpp
来自「一个以前收集的基于C/S架构的ERP客户端源代码」· C++ 代码 · 共 588 行 · 第 1/2 页
CPP
588 行
//---------------------------------------------------------------------------
#include <vcl.h>
#include "Glbm_Project.h"
#include "Glbm_ProjF.h"
//---------------------------------------------------------------------------
#pragma hdrstop
#pragma package(smart_init)
#pragma link "QueryBaseForm"
#pragma link "SDGrid"
#pragma link "KSAdvReport"
#pragma resource "*.dfm"
TfrmGlbm_Project *frmGlbm_Project;
//---------------------------------------------------------------------------
__fastcall TfrmGlbm_Project::TfrmGlbm_Project(TComponent* Owner)
: TQueryBaseForm(Owner)
{
FGlbProjSign=0;
FCancelQuery=false;
RstProject=NULL;
lblProject->Caption="";
lblFcMonth->Caption="";
QueryGrid=sgGlbm_Project;
}
//---------------------------------------------------------------------------
__fastcall TfrmGlbm_Project::TfrmGlbm_Project(TComponent* Owner, HWND chWnd, AnsiString MidCode,AnsiString WhereStr)
: TQueryBaseForm(Owner, chWnd, MidCode, WhereStr)
{
FGlbProjSign=0;
FCancelQuery=false;
RstProject=NULL;
lblProject->Caption="";
lblFcMonth->Caption="";
QueryGrid=sgGlbm_Project;
}
//---------------------------------------------------------------------------
void __fastcall TfrmGlbm_Project::tbQueryClick(TObject *Sender)
{
if(!ShowQueryWindow())
return;
try{
StartWaitForm("正在查询,请稍候...");
//填充项目
FillGridWithProject();
if(FCurrencyInfo==g_sdCurrencyName)
FillGridWithData();
else
FillGridWithDataW();
}
__finally
{
EndWaitForm();
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmGlbm_Project::InitSDGridGlbm_Project()
{
sgGlbm_ProjectW->Cells[5][1]="原币";
sgGlbm_ProjectW->Cells[6][1]="本币";
sgGlbm_ProjectW->Cells[7][1]="原币";
sgGlbm_ProjectW->Cells[8][1]="本币";
sgGlbm_ProjectW->Cells[9][1]="";
sgGlbm_ProjectW->Cells[10][1]="原币";
sgGlbm_ProjectW->Cells[11][1]="本币";
}
//---------------------------------------------------------------------------
void __fastcall TfrmGlbm_Project::InitSdForm(AnsiString tCurrency)
{
if(FCurrencyInfo==g_sdCurrencyName ||FCancelQuery)
{
sgGlbm_Project->Align=alClient;
sgGlbm_Project->Visible=true;
sgGlbm_ProjectW->Visible=false;
}
else
{
sgGlbm_Project->Visible=false;
sgGlbm_ProjectW->Visible=true;
sgGlbm_ProjectW->Align=alClient;
InitSDGridGlbm_Project();
}
}
//---------------------------------------------------------------------------
bool __fastcall TfrmGlbm_Project::ShowQueryWindow()
{
if(FGlbProjSign==1)
{
InitSdForm(FCurrencyInfo);
return true;
}
TfrmGlbm_ProjF *Glbm_ProjFfrm;
Glbm_ProjFfrm=new TfrmGlbm_ProjF(this);
Glbm_ProjFfrm->ShowModal();
//回传参数
FCancelQuery=Glbm_ProjFfrm->CancelQuery;
FilterStr=Glbm_ProjFfrm->CreateSqlString;
FcMonthFilStr=Glbm_ProjFfrm->FcMonthFilStr;
FCurrencyInfo=Glbm_ProjFfrm->FCurrencyInfo;
FcMonthInfo=Glbm_ProjFfrm->FcMonthInfo;
FGlb_ProjGlkm=Glbm_ProjFfrm->FGlkmCode;
FProjectType=Glbm_ProjFfrm->FProjectType;
FProjectFrom=Glbm_ProjFfrm->FProjectFrom;
FProjectTo=Glbm_ProjFfrm->FProjectTo;
//初始化Form
InitSdForm(FCurrencyInfo);
if(FCancelQuery)
{
delete Glbm_ProjFfrm;
return false;
}
delete Glbm_ProjFfrm;
return true;
}
//---------------------------------------------------------------------------
void __fastcall TfrmGlbm_Project::ClearControl(bool BringToNext)
{
return;
}
//---------------------------------------------------------------------------
void __fastcall TfrmGlbm_Project::GetDataFromComObject()
{
return;
}
//---------------------------------------------------------------------------
void __fastcall TfrmGlbm_Project::WaitUserInput()
{
return;
}
//---------------------------------------------------------------------------
void __fastcall TfrmGlbm_Project::RefreshGridData(int mAction)
{
return;
}
//---------------------------------------------------------------------------
void __fastcall TfrmGlbm_Project::DisplayBill()
{
return;
}
//---------------------------------------------------------------------------
void __fastcall TfrmGlbm_Project::GetBill(AnsiString BillID)
{
return;
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmGlbm_Project::GetHeadQueryStr(AnsiString tFcMonth,AnsiString tGlkmCode)
{
AnsiString Selectstr,Fromstr,Wherestr,Orderstr;
Selectstr="select PzhDate,PzhFvct,PzhCode,NoteBookText=IsNULL(NoteBookText,''),PzdDir,PzdGlkm,GlkmName,";
Selectstr+="PzdAmt,PzdWbAmt,PzdQty,GlkmDir";
Fromstr=" from sdPzh,sdPzd,sdGlkm,sdNoteBook";
FGlb_ProjCode=RstProject->FieldByName("ProjectCode");
if(FilterStr=="")
{
if(FGlbProjSign==1)
{
if(FPzUnPosted==1)
Wherestr=" where PzhCode=PzdCode and PzdZy*=NoteBookCode and PzdGlkm=GlkmCode and PzhCheck=1";
else
Wherestr=" where PzhCode=PzdCode and PzdZy*=NoteBookCode and PzdGlkm=GlkmCode and PzhCheck=1 and PzhPost=1";
Wherestr+=" And PzdGlkm Like '"+FGlb_ProjGlkm+"%' and "+sProjectCode+"='"+FGlb_ProjCode+"' and PzhFmonth='"+FGlb_ProjFmonth+"'";
Wherestr+=" And exists(select * from sdPzd where PzdCode=sdPzh.PzhCode and PzdGlkm Like '"+FGlb_ProjGlkm+"%' and "+sProjectCode+"='"+FGlb_ProjCode+"')";
}
else
{
Wherestr=" where PzhCode=PzdCode and PzdZy*=NoteBookCode and PzdGlkm=GlkmCode and PzhCheck=1";
Wherestr+=" And PzdGlkm Like '"+tGlkmCode+"%' and "+sProjectCode+"='"+FGlb_ProjCode+"' and PzhFmonth='"+tFcMonth+"'";
Wherestr+=" And exists(select * from sdPzd where PzdCode=sdPzh.PzhCode and PzdGlkm Like '"+tGlkmCode+"%' and "+sProjectCode+"='"+FGlb_ProjCode+"')";
}
}
else
{
if(FGlbProjSign==1)
{
Wherestr=" where PzhCode=PzdCode and PzdZy*=NoteBookCode and PzdGlkm=GlkmCode";
Wherestr+=" And PzdGlkm Like '"+FGlb_ProjGlkm+"%' and "+sProjectCode+"='"+FGlb_ProjCode+"' and PzhFmonth='"+FGlb_ProjFmonth+"'";
Wherestr+=" And exists(select * from sdPzd where PzdCode=sdPzh.PzhCode and PzdGlkm Like '"+FGlb_ProjGlkm+"%' and "+sProjectCode+"='"+FGlb_ProjCode+"')";
}
else
{
Wherestr=" where PzhCode=PzdCode and PzdZy*=NoteBookCode and PzdGlkm=GlkmCode";
Wherestr+=" And PzdGlkm Like '"+tGlkmCode+"%' and "+sProjectCode+"='"+FGlb_ProjCode+"' and PzhFmonth='"+tFcMonth+"'";
Wherestr+=" And exists(select * from sdPzd where PzdCode=sdPzh.PzhCode and PzdGlkm Like '"+tGlkmCode+"%' and "+sProjectCode+"='"+FGlb_ProjCode+"')";
}
Wherestr=Wherestr+" And "+FilterStr;
}
Orderstr=" order by PzhDate,PzdGlkm";
sSQL=Selectstr+Fromstr+Wherestr+Orderstr;
return(sSQL);
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmGlbm_Project::GetSpace(int iNum)
{
AnsiString strSpace;
for(int i=1;i<iNum;i++)
strSpace=strSpace+AnsiString(" ");
return strSpace;
}
//---------------------------------------------------------------------------
void __fastcall TfrmGlbm_Project::FillGridWithProject()
{
int iType;
AnsiString tSQL,tWherestr;
RstProject=new TComResultSet(Handle,g_ClientHandle);
iType=FProjectType.SubString(1,FProjectType.Pos("-")-1).ToInt();
switch (iType)
{
case 1: //Dept
if(FProjectFrom!="")
tWherestr="DeptCode>='"+FProjectFrom+"' and ";
if(FProjectTo!="")
tWherestr+="DeptCode<='"+FProjectTo+"' and ";
if(tWherestr.Length()>5)
tWherestr=tWherestr.SubString(1,tWherestr.Length()-5);
else
tWherestr="";
if(tWherestr!="")
tSQL="select ProjectCode=DeptCode,ProjectName=DeptName from sdDept where DeptEnd=1 and "+tWherestr+" order by DeptCode";
else
tSQL="select ProjectCode=DeptCode,ProjectName=DeptName from sdDept where DeptEnd=1 order by DeptCode";
sProjectCode="PzdDept";
break;
case 2: //Client
if(FProjectFrom!="")
tWherestr="ClientCode>='"+FProjectFrom+"' and ";
if(FProjectTo!="")
tWherestr+="ClientCode<='"+FProjectTo+"' and ";
if(tWherestr.Length()>5)
tWherestr=tWherestr.SubString(1,tWherestr.Length()-5);
else
tWherestr="";
if(tWherestr!="")
tSQL="select ProjectCode=ClientCode,ProjectName=ClientName from sdClient where ClientCancel=0 and "+tWherestr+" order by ClientCode";
else
tSQL="select ProjectCode=ClientCode,ProjectName=ClientName from sdClient where ClientCancel=0 order by ClientCode";
sProjectCode="PzdClient";
break;
case 3: //Supply
if(FProjectFrom!="")
tWherestr="SupplyCode>='"+FProjectFrom+"' and ";
if(FProjectTo!="")
tWherestr+="SupplyCode<='"+FProjectTo+"' and ";
if(tWherestr.Length()>5)
tWherestr=tWherestr.SubString(1,tWherestr.Length()-5);
else
tWherestr="";
if(tWherestr!="")
tSQL="select ProjectCode=SupplyCode,ProjectName=SupplyName from sdSupply where SupplyCancel=0 and "+tWherestr+" order by SupplyCode";
else
tSQL="select ProjectCode=SupplyCode,ProjectName=SupplyName from sdSupply where SupplyCancel=0 order by SupplyCode";
sProjectCode="PzdSupply";
break;
case 4: //Employee
if(FProjectFrom!="")
tWherestr="EmployeeCode>='"+FProjectFrom+"' and ";
if(FProjectTo!="")
tWherestr+="EmployeeCode<='"+FProjectTo+"' and ";
if(tWherestr.Length()>5)
tWherestr=tWherestr.SubString(1,tWherestr.Length()-5);
else
tWherestr="";
if(tWherestr!="")
tSQL="select ProjectCode=EmployeeCode,ProjectName=EmployeeName from sdEmployee where EmployeeState=0 and "+tWherestr+" order by EmployeeCode";
else
tSQL="select ProjectCode=EmployeeCode,ProjectName=EmployeeName from sdEmployee where EmployeeState=0 order by EmployeeCode";
sProjectCode="PzdEmployee";
break;
}
RstProject->Open(tSQL,"");
RstProject->MoveFirst();
}
//---------------------------------------------------------------------------
void __fastcall TfrmGlbm_Project::InitLableCaption()
{
int iType;
iType=FProjectType.SubString(1,FProjectType.Pos("-")-1).ToInt();
switch (iType)
{
case 1:
lblProject->Caption="核算项目:部门-["+RstProject->FieldByName("ProjectCode")+"]"+
RstProject->FieldByName("ProjectName");
break;
case 2:
lblProject->Caption="核算项目:客户-["+RstProject->FieldByName("ProjectCode")+"]"+
RstProject->FieldByName("ProjectName");
break;
case 3:
lblProject->Caption="核算项目:供应商-["+RstProject->FieldByName("ProjectCode")+"]"+
RstProject->FieldByName("ProjectName");
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?