📄 vw_labh.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#include "VW_Labh.h"
#include "VW_Labd.h"
//---------------------------------------------------------------------------
#pragma hdrstop
#pragma package(smart_init)
#pragma link "QueryBaseForm"
#pragma link "SDGrid"
#pragma resource "*.dfm"
TfrmVW_Labh *frmVW_Labh;
//---------------------------------------------------------------------------
__fastcall TfrmVW_Labh::TfrmVW_Labh(TComponent* Owner)
: TQueryBaseForm(Owner)
{
FilterStr="";
sSQL="";
RecentBillCode="";
}
//---------------------------------------------------------------------------
void __fastcall TfrmVW_Labh::tbQueryClick(TObject *Sender)
{
if(!ShowQueryWindow())
return;
try{
StartWaitForm("正在查询,请稍候...");
FillGridWithData();
}
__finally
{
EndWaitForm();
}
}
//---------------------------------------------------------------------------
bool __fastcall TfrmVW_Labh::ShowQueryWindow()
{
TfrmQuForm *FQuery=new TfrmQuForm(this,this->Name);
FQuery->ShowModal();
if(FQuery->CancelQuery)
return false;
FilterStr=FQuery->CreateSqlString;
delete FQuery;
return true;
}
//---------------------------------------------------------------------------
void __fastcall TfrmVW_Labh::ClearControl(bool BringToNext)
{
return;
}
//---------------------------------------------------------------------------
void __fastcall TfrmVW_Labh::GetDataFromComObject()
{
return;
}
//---------------------------------------------------------------------------
void __fastcall TfrmVW_Labh::WaitUserInput()
{
return;
}
//---------------------------------------------------------------------------
void __fastcall TfrmVW_Labh::RefreshGridData(int mAction)
{
return;
}
//---------------------------------------------------------------------------
void __fastcall TfrmVW_Labh::DisplayBill()
{
return;
}
//---------------------------------------------------------------------------
void __fastcall TfrmVW_Labh::GetBill(AnsiString BillID)
{
return;
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmVW_Labh::GetHeadQueryStr()
{
AnsiString Selectstr,Fromstr,Wherestr,Orderstr;
Selectstr="select "
+AnsiString("LabhCode, ")
+AnsiString("LabhFmonth, ")
+AnsiString("LabhDate, ")
+AnsiString("LabhState1, ")
+AnsiString("LabhShop1, ")
+AnsiString("LabhTeam1, ")
+AnsiString("LabhCheck1, ")
+AnsiString("LabhChecker, ")
+AnsiString("LabhCheckDate, ")
+AnsiString("LabhUser1 ");
Fromstr=" from SDVW_Labh ";
if(FilterStr=="")
Wherestr="";
else
Wherestr=" where "+FilterStr;
Orderstr=" order by LabhDate desc,LabhCode desc ";
sSQL=Selectstr+Fromstr+Wherestr+Orderstr;
return(sSQL);
}
//---------------------------------------------------------------------------
void __fastcall TfrmVW_Labh::FillGridWithData()
{
TComResultSet *RsQuery;
AnsiString ItemStr,sSql;
sSql=GetHeadQueryStr(); //取Head查询的SQL语句
if(sSql=="")
return;
sgLabh->RowCount=1;
RecentBillCode="";
RsQuery=NewResultSet();
RsQuery->Open(sSql,"");
RsQuery->MoveFirst();
while(RsQuery->Eof == 0)
{
ItemStr= RsQuery->FieldByName("LabhCode")+
"\t"+RsQuery->FieldByName("LabhFmonth")+
"\t"+RsQuery->FieldByName("LabhDate")+
"\t"+RsQuery->FieldByName("LabhState1")+
"\t"+RsQuery->FieldByName("LabhShop1")+
"\t"+RsQuery->FieldByName("LabhTeam1")+
"\t"+RsQuery->FieldByName("LabhCheck1")+
"\t"+RsQuery->FieldByName("LabhCheckDate")+
"\t"+RsQuery->FieldByName("LabhChecker")+
"\t"+RsQuery->FieldByName("LabhUser1");
sgLabh->AddItem(ItemStr);
RsQuery->MoveNext();
}
RsQuery->Close();
delete RsQuery;
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmVW_Labh::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[0][sgLabh->Row]+"'";
Orderstr=" order by LabdLine ";
return(Selectstr+Fromstr+Wherestr+Orderstr);
}
//---------------------------------------------------------------------------
void __fastcall TfrmVW_Labh::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[0][ARow];
VW_Labd->scLabhFmonth->Text=sgLabh->Cells[1][ARow];
VW_Labd->deLabhDate->Text=sgLabh->Cells[2][ARow];
VW_Labd->scLabhShop->Text=sgLabh->Cells[4][ARow];
VW_Labd->sgLabd->RowCount=1;
RsQuery=NewResultSet();
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;
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmVW_Labh::muFirstClick(TObject *Sender)
{
if(sgLabh->RowCount > 1)
sgLabh->Row=1;
}
//---------------------------------------------------------------------------
void __fastcall TfrmVW_Labh::muNextClick(TObject *Sender)
{
if(sgLabh->RowCount > 1 && sgLabh->Row < sgLabh->RowCount-1)
sgLabh->Row=sgLabh->Row+1;
}
//---------------------------------------------------------------------------
void __fastcall TfrmVW_Labh::muLastClick(TObject *Sender)
{
if(sgLabh->RowCount > 1)
sgLabh->Row=sgLabh->RowCount-1;
}
//---------------------------------------------------------------------------
void __fastcall TfrmVW_Labh::tbRefreshClick(TObject *Sender)
{
if(sSQL=="")
return;
FillGridWithData();
}
//---------------------------------------------------------------------------
void __fastcall TfrmVW_Labh::sgLabhDblClick(TObject *Sender)
{
int ARow=sgLabh->Row;
if(ARow>0)
FillGridWithDetail();
}
//---------------------------------------------------------------------------
void __fastcall TfrmVW_Labh::muPreviousClick(TObject *Sender)
{
if(sgLabh->RowCount > 1 && sgLabh->Row > 1)
sgLabh->Row=sgLabh->Row-1;
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -