📄 vw_weph.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#include "VW_Weph.h"
#include "VW_Wepd.h"
//---------------------------------------------------------------------------
#pragma hdrstop
#pragma package(smart_init)
#pragma link "QueryBaseForm"
#pragma link "SDGrid"
#pragma resource "*.dfm"
TfrmVW_Weph *frmVW_Weph;
//---------------------------------------------------------------------------
__fastcall TfrmVW_Weph::TfrmVW_Weph(TComponent* Owner)
: TQueryBaseForm(Owner)
{
FilterStr="";
sSQL="";
RecentBillCode="";
}
//---------------------------------------------------------------------------
void __fastcall TfrmVW_Weph::tbQueryClick(TObject *Sender)
{
if(!ShowQueryWindow())
return;
try{
StartWaitForm("正在查询,请稍候...");
FillGridWithData();
}
__finally
{
EndWaitForm();
}
}
//---------------------------------------------------------------------------
bool __fastcall TfrmVW_Weph::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_Weph::ClearControl(bool BringToNext)
{
return;
}
//---------------------------------------------------------------------------
void __fastcall TfrmVW_Weph::GetDataFromComObject()
{
return;
}
//---------------------------------------------------------------------------
void __fastcall TfrmVW_Weph::WaitUserInput()
{
return;
}
//---------------------------------------------------------------------------
void __fastcall TfrmVW_Weph::RefreshGridData(int mAction)
{
return;
}
//---------------------------------------------------------------------------
void __fastcall TfrmVW_Weph::DisplayBill()
{
return;
}
//---------------------------------------------------------------------------
void __fastcall TfrmVW_Weph::GetBill(AnsiString BillID)
{
return;
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmVW_Weph::GetHeadQueryStr()
{
AnsiString Selectstr,Fromstr,Wherestr,Orderstr;
Selectstr="select distinct "
+AnsiString("WephCode, ")
+AnsiString("WephFmonth, ")
+AnsiString("WephDate, ")
+AnsiString("WephState1, ")
+AnsiString("WephPosType, ")
+AnsiString("WephCheck1, ")
+AnsiString("WephChecker, ")
+AnsiString("WephCheckDate, ")
+AnsiString("WephUser1 ");
Fromstr=" from SDVW_Weph ";
if(FilterStr=="")
Wherestr="";
else
Wherestr=" where "+FilterStr;
Orderstr=" order by WephDate desc,WephCode desc ";
sSQL=Selectstr+Fromstr+Wherestr+Orderstr;
return(sSQL);
}
//---------------------------------------------------------------------------
void __fastcall TfrmVW_Weph::FillGridWithData()
{
TComResultSet *RsQuery;
AnsiString ItemStr,sSql;
sSql=GetHeadQueryStr(); //取Head查询的SQL语句
if(sSql=="")
return;
sgWeph->RowCount=1;
RecentBillCode="";
RsQuery=NewResultSet();
RsQuery->Open(sSql,"");
RsQuery->MoveFirst();
while(RsQuery->Eof == 0)
{
ItemStr=RsQuery->FieldByName("WephCode")+
"\t"+RsQuery->FieldByName("WephFmonth")+
"\t"+RsQuery->FieldByName("WephDate")+
"\t"+RsQuery->FieldByName("WephState1")+
"\t"+RsQuery->FieldByName("WephPosType")+
"\t"+RsQuery->FieldByName("WephCheck1")+
"\t"+RsQuery->FieldByName("WephCheckDate")+
"\t"+RsQuery->FieldByName("WephChecker")+
"\t"+RsQuery->FieldByName("WephUser1");
sgWeph->AddItem(ItemStr);
RsQuery->MoveNext();
}
RsQuery->Close();
delete RsQuery;
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmVW_Weph::GetDetailQueryStr()
{
AnsiString Selectstr,Fromstr,Wherestr,Orderstr;
if(sgWeph->RowCount < 2)
return("");
if(sgWeph->Row == 0)
return("");
Selectstr="select "
+AnsiString("WepdLine, ")
+AnsiString("WepdWo, ")
+AnsiString("WepdGoods, ")
+AnsiString("WepdLoc, ")
+AnsiString("WepdIQty, ") //入库数量
+AnsiString("WepdCQty, ") //完工数量
+AnsiString("WepdEQty, ") //合格数量
+AnsiString("WepdWQty, ") //返修数量
+AnsiString("WepdRQty, ") //次品数量
+AnsiString("WepdSQty, ") //废品数量
+AnsiString("WepdSod, ")
+AnsiString("WepdSodLine, ")
+AnsiString("WepdBatch, ")
+AnsiString("WepdWsr ");
Fromstr=" from SDVW_Wepd ";
Wherestr=" where WepdCode='"+sgWeph->Cells[0][sgWeph->Row]+"'";
Orderstr=" order by WepdLine ";
return(Selectstr+Fromstr+Wherestr+Orderstr);
}
//---------------------------------------------------------------------------
void __fastcall TfrmVW_Weph::FillGridWithDetail()
{
TComResultSet *RsQuery;
AnsiString ItemStr,sSql;
TfrmVW_Wepd *VW_Wepd;
sSql=GetDetailQueryStr(); //取Detail查询的SQL语句
if(sSql=="")
return;
try
{
VW_Wepd=new TfrmVW_Wepd(this);
int ARow=sgWeph->Row;
VW_Wepd->seWephCode->Text=sgWeph->Cells[0][ARow];
VW_Wepd->deWephDate->Text=sgWeph->Cells[2][ARow];
VW_Wepd->scWephFmonth->Text=sgWeph->Cells[1][ARow];
VW_Wepd->scWephPosType->Text=sgWeph->Cells[4][ARow];
VW_Wepd->sgWepd->RowCount=1;
RsQuery=NewResultSet();
RsQuery->Open(sSql,"");
RsQuery->MoveFirst();
while(RsQuery->Eof == 0)
{
ItemStr= RsQuery->FieldByName("WepdLine")+
"\t"+RsQuery->FieldByName("WepdWo")+
"\t"+RsQuery->FieldByName("WepdGoods")+
"\t"+RsQuery->FieldByName("WepdLoc")+
"\t"+RsQuery->FieldByName("WepdIQty")+
"\t"+RsQuery->FieldByName("WepdCQty")+
"\t"+RsQuery->FieldByName("WepdEQty")+
"\t"+RsQuery->FieldByName("WepdWQty")+
"\t"+RsQuery->FieldByName("WepdRQty")+
"\t"+RsQuery->FieldByName("WepdSQty")+
"\t"+RsQuery->FieldByName("WepdSod")+
"\t"+RsQuery->FieldByName("WepdSodLine")+
"\t"+RsQuery->FieldByName("WepdBatch")+
"\t"+RsQuery->FieldByName("WepdWsr");
VW_Wepd->sgWepd->AddItem(ItemStr);
RsQuery->MoveNext();
}
RsQuery->Close();
delete RsQuery;
if(VW_Wepd->sgWepd->RowCount > 1)
VW_Wepd->ShowModal();
}
__finally
{
delete VW_Wepd;
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmVW_Weph::muFirstClick(TObject *Sender)
{
if(sgWeph->RowCount > 1)
sgWeph->Row=1;
}
//---------------------------------------------------------------------------
void __fastcall TfrmVW_Weph::muNextClick(TObject *Sender)
{
if(sgWeph->RowCount > 1 && sgWeph->Row < sgWeph->RowCount-1)
sgWeph->Row=sgWeph->Row+1;
}
//---------------------------------------------------------------------------
void __fastcall TfrmVW_Weph::muLastClick(TObject *Sender)
{
if(sgWeph->RowCount > 1)
sgWeph->Row=sgWeph->RowCount-1;
}
//---------------------------------------------------------------------------
void __fastcall TfrmVW_Weph::tbRefreshClick(TObject *Sender)
{
if(sSQL=="")
return;
FillGridWithData();
}
//---------------------------------------------------------------------------
void __fastcall TfrmVW_Weph::sgWephDblClick(TObject *Sender)
{
int ARow=sgWeph->Row;
if(ARow>0)
FillGridWithDetail();
}
//---------------------------------------------------------------------------
void __fastcall TfrmVW_Weph::muPreviousClick(TObject *Sender)
{
if(sgWeph->RowCount > 1 && sgWeph->Row > 1)
sgWeph->Row=sgWeph->Row-1;
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -