📄 labhreport.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "LabhReport.h"
#include "VW_Labd.h"
#include "WnQuery.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "DateEdit"
#pragma link "GroupBaseForm"
#pragma link "SDComboBox"
#pragma link "SDEdit"
#pragma link "SDGrid"
#pragma link "KSAdvReport"
#pragma resource "*.dfm"
TfrmLabhReport *frmLabhReport;
//---------------------------------------------------------------------------
__fastcall TfrmLabhReport::TfrmLabhReport(TComponent* Owner, HWND chWnd, AnsiString MidCode,AnsiString WhereStr)
: TGroupBaseForm(Owner,chWnd,MidCode,WhereStr)
{
OwGrid=sgLabh;
}
//---------------------------------------------------------------------------
void __fastcall TfrmLabhReport::InitEditControl()
{
AddGroupItem(edLabhCodeBox,edLabhCode,"LabhCode","LabhCode","\t单据编号");
AddGroupItem(cbLabhFMonthBox,cbLabhFMonth,"LabhFmonth","LabhFmonth","\t财务月份");
AddGroupItem(cbLabhShopBox,cbLabhShop,"LabhShop1","LabhShop1","\t车间");
AddGroupItem(cbLabhTeamBox,cbLabhTeam,"LabhTeam1","LabhTeam1","\t班组");
l_SumField ="";
l_SumField+="";
l_SumDisp="";
l_DefField="LabhCode,LabhFmonth,LabhDate,LabhState1,LabhShop1,LabhTeam1,LabhCheck1,LabhChecker,LabhCheckDate,LabhUser1 from SDVW_Labh ";
l_DefDisp="\t单据编号\t财务月份\t制单日期\t状态\t车间\t班组\t审核\t审核日期\t审核人\t制单人";
s_DateField="LabhDate";
FillComboBox(Handle,cbLabhFMonth,"SELECT FcMonth FROM sdFc order by FcMonth","FcMonth");
FillComboBox(Handle,cbLabhShop,"SELECT DISTINCT LabhShop1=IsNull((select ShopName from sdShop where ShopCode=LabhShop),'') from sdLabh","LabhShop1","LabhShop1");
FillComboBox(Handle,cbLabhTeam,"SELECT DISTINCT LabhTeam1=isnull((select TeamName from sdTeam where TeamCode=LabhTeam),'') FROM sdLabh","LabhTeam1","LabhTeam1");
}
//---------------------------------------------------------------------------
void __fastcall TfrmLabhReport::edLabhCodeButtonClick(TObject *Sender)
{
AnsiString SqlStr;
SqlStr="004[单据编号][财务月份][制单日期][状态]select LabhCode,LabhFmonth,LabhDate,LabhState1 from SDVW_Labh order by LabhDate DESC,LabhCode";
TfrmWnQuery *p;
try
{
StartWaitForm("正在查询,请稍候...");
p=new TfrmWnQuery(this,"单据编号查询",SqlStr);
}
__finally
{
EndWaitForm();
}
if(p->ShowModal()==mrOk)
{
edLabhCode->Text=(p->ColData[1]);
}
delete p;
}
//---------------------------------------------------------------------------
void __fastcall TfrmLabhReport::dtDateEnChange(TObject *Sender)
{
dtDateBg->Text=dtDateEn->Text;
}
//---------------------------------------------------------------------------
void __fastcall TfrmLabhReport::sgLabhDblClick(TObject *Sender)
{
int ARow=sgLabh->Row;
if(ARow>0)
FillGridWithDetail();
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmLabhReport::GetDetailQueryStr()
{
AnsiString Selectstr,Fromstr,Wherestr,Orderstr;
if(sgLabh->RowCount < 2)
return("");
if(sgLabh->Row == 0)
return("");
Selectstr="select "
+AnsiString("LabdLine, ")
+AnsiString("LabdWo, ")
+AnsiString("LabdProcess, ")
+AnsiString("LabdEmployee, ")
+AnsiString("LabdEmployeeName, ")
+AnsiString("LabdDType, ")
+AnsiString("LabdTime, ")
+AnsiString("LabdPrice, ")
+AnsiString("LabdDesc ");
Fromstr=" from SDVW_Labd ";
Wherestr=" where LabdCode='"+sgLabh->Cells[1][sgLabh->Row]+"'";
Orderstr=" order by LabdLine ";
return(Selectstr+Fromstr+Wherestr+Orderstr);
}
//---------------------------------------------------------------------------
void __fastcall TfrmLabhReport::FillGridWithDetail()
{
TComResultSet *RsQuery;
AnsiString ItemStr,sSql;
TfrmVW_Labd *VW_Labd;
sSql=GetDetailQueryStr(); //取Detail查询的SQL语句
if(sSql=="")
return;
try
{
VW_Labd=new TfrmVW_Labd(this);
int ARow=sgLabh->Row;
VW_Labd->seLabhCode->Text=sgLabh->Cells[1][ARow];
VW_Labd->scLabhFmonth->Text=sgLabh->Cells[2][ARow];
VW_Labd->deLabhDate->Text=sgLabh->Cells[3][ARow];
VW_Labd->scLabhShop->Text=sgLabh->Cells[5][ARow];
VW_Labd->sgLabd->RowCount=1;
RsQuery=new TComResultSet(Handle,g_ClientHandle);
RsQuery->Open(sSql,"");
RsQuery->MoveFirst();
while(RsQuery->Eof == 0)
{
ItemStr= RsQuery->FieldByName("LabdLine")+
"\t"+RsQuery->FieldByName("LabdWo")+
"\t"+RsQuery->FieldByName("LabdProcess")+
"\t"+RsQuery->FieldByName("LabdEmployee")+
"\t"+RsQuery->FieldByName("LabdEmployeeName")+
"\t"+RsQuery->FieldByName("LabdDType")+
"\t"+RsQuery->FieldByName("LabdTime")+
"\t"+RsQuery->FieldByName("LabdPrice")+
"\t"+RsQuery->FieldByName("LabdDesc");
VW_Labd->sgLabd->AddItem(ItemStr);
RsQuery->MoveNext();
}
RsQuery->Close();
delete RsQuery;
if(VW_Labd->sgLabd->RowCount > 1)
VW_Labd->ShowModal();
}
__finally
{
delete VW_Labd;
}
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -