pohstop.cpp
来自「一个以前收集的基于C/S架构的ERP客户端源代码」· C++ 代码 · 共 242 行
CPP
242 行
//---------------------------------------------------------------------------
#include <vcl.h>
#include "PohStop.h"
//---------------------------------------------------------------------------
#pragma hdrstop
#pragma package(smart_init)
#pragma link "DateEdit"
#pragma link "ListBaseForm"
#pragma link "SDComboBox"
#pragma link "SDEdit"
#pragma link "SDGrid"
#pragma resource "*.dfm"
TfrmPohStop *frmPohStop;
//---------------------------------------------------------------------------
__fastcall TfrmPohStop::TfrmPohStop(TComponent* Owner, HWND chWnd, AnsiString MidCode,AnsiString WhereStr)
: TListBaseForm(Owner,chWnd,MidCode,WhereStr)
{
}
//---------------------------------------------------------------------------
void __fastcall TfrmPohStop::FillHeadObjToGrid()
{
AnsiString ItemStr;
try
{
StartWaitForm("正在获取数据...");
comServer->FilterString=WideString(WhereStr);
comServer->Query();
if(comServer->RecordCount>0)
{
sgPohCheck->RowCount=1;
for(int i=0;i<comServer->RecordCount;i++)
{
comServer->LocateByIndex(i);
ItemStr="\t"+ AnsiString(" ")+
"\t"+ GetHeadValue("PohCode")+
"\t"+ GetHeadValue("PohDate")+
"\t"+ GetHeadValue("PohSupply")+
"\t"+ GetHeadValue("PohCurrency")+
"\t"+ GetHeadValue("PohAmt")+
"\t"+ GetHeadValue("PohBuyer")+
"\t"+ GetHeadValue("PohContract")+
"\t"+ GetHeadValue("PohSugDate");
sgPohCheck->AddItem(ItemStr);
}
}
else
{
sgPohCheck->RowCount=1;
sgPodCheck->RowCount=1;
}
}
__finally
{
EndWaitForm();
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPohStop::GetWhereStrToSQL()
{
WhereStr="PohCheck=1 and PohCancel=0 and PohStop=0 and PohClose=0 and ";
if(Trim(sePohCodeF->Text).IsEmpty()==false)
WhereStr=WhereStr+ "PohCode>='"+Trim(sePohCodeF->Text)+"' and ";
if(Trim(sePohCodeT->Text).IsEmpty()==false)
WhereStr=WhereStr+ "PohCode<='"+Trim(sePohCodeT->Text)+"' and ";
if(Trim(dePohDateF->Text).IsEmpty()==false)
WhereStr=WhereStr+ "PohDate>='"+FormatDateTime("yyyy-mm-dd",dePohDateF->Date)+"' and ";
if(Trim(dePohDateT->Text).IsEmpty()==false)
WhereStr=WhereStr+ "PohDate<='"+FormatDateTime("yyyy-mm-dd",dePohDateT->Date)+"' and ";
if(Trim(scPohBuyerCode->Text).IsEmpty()==false)
WhereStr=WhereStr+ "PohBuyer like '"+Trim(scPohBuyerCode->ItemData[cbItem2])+"' and ";
if(Trim(scPohSupplyCode->Text).IsEmpty()==false)
WhereStr=WhereStr+ "PohSupply like '"+Trim(scPohSupplyCode->ItemData[cbItem2])+"' and ";
if (WhereStr.Length() > 5)
WhereStr=WhereStr.SubString(1,WhereStr.Length()-5);
else
WhereStr="";
}
//---------------------------------------------------------------------------
void __fastcall TfrmPohStop::InitEditControl()
{
sgPohCheck->RowCount=1;
sgPodCheck->RowCount=1;
btnStop->Enabled=false;
sePohCodeF->Text="";
sePohCodeT->Text="";
dePohDateF->Text="";
dePohDateT->Text=dePohDateT->InitDate;
scPohBuyerCode->Text="";
scPohSupplyCode->Text="";
sbBar->Panels->Items[1]->Text="操作员:"+g_sdUserCode;
sbBar->Panels->Items[2]->Text=g_sdCompanyName;
sbBar->Panels->Items[3]->Text=g_sdCurDate;
}
//---------------------------------------------------------------------------
void __fastcall TfrmPohStop::ChangeToBrowseState(bool agree)
{
return;
}
//---------------------------------------------------------------------------
void __fastcall TfrmPohStop::AddDetailObjToGrid(AnsiString s_Code)
{
AnsiString ItemStr;
sgPodCheck->RowCount=1;
comServer->LocateByKey(WideString(s_Code));
if(comServer->RecordCount>0)
{
for (int i=0;i<comServer->ItemCount;i++)
{
comServer->LocateItemByIndex(i);
l_Query->LocateByKey(GetDetailValue("PodGoods"));
ItemStr="\t"+GetDetailValue("PodCode")+
"\t"+GetDetailValue("PodLine")+
"\t"+GetDetailValue("PodGoods")+
"\t"+l_Query->FieldByName("goodsname")+
"\t"+l_Query->FieldByName("goodsspec")+
"\t"+GetDetailValue("PodUnit")+
"\t"+GetDetailValue("PodReqDate")+
"\t"+GetDetailValue("PodQty")+
"\t"+GetDetailValue("PodDept")+
"\t"+GetDetailValue("PodLoc")+
"\t"+GetDetailValue("PodSo");
sgPodCheck->AddItem(ItemStr,i+1);
}
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPohStop::DelDetailObjFromGrid(AnsiString s_Code)
{
AnsiString m;
for(int i=sgPodCheck->RowCount;i>0;i--)
{
m = Trim(sgPodCheck->Cells[1][i]);
if(m==s_Code)
sgPodCheck->RemoveItem(i);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPohStop::btnClearClick(TObject *Sender)
{
InitEditControl();
}
//---------------------------------------------------------------------------
void __fastcall TfrmPohStop::btnQueryClick(TObject *Sender)
{
GetWhereStrToSQL();
FillHeadObjToGrid();
}
//---------------------------------------------------------------------------
void __fastcall TfrmPohStop::FormShow(TObject *Sender)
{
FillComboBox(Handle,scPohBuyerCode,"select BuyerCode,BuyerName from sdBuyer order By BuyerCode","BuyerName","BuyerCode");
FillComboBox(Handle,scPohSupplyCode,"select SupplyCode,SupplyName from sdSupply order By SupplyCode","SupplyName","SupplyCode");
InitEditControl();
l_Query->Close();
l_Query->Open("select goodsname,goodscode,goodsspec from sdgoods","goodscode");
}
//---------------------------------------------------------------------------
void __fastcall TfrmPohStop::BitExitClick(TObject *Sender)
{
frmPohStop->Close();
}
//---------------------------------------------------------------------------
void __fastcall TfrmPohStop::btnStopClick(TObject *Sender)
{
for(int i=sgPohCheck->RowCount-1; i>0;i--)
{
if(sgPohCheck->Cells[1][i]=="√")
{
if(comServer->LocateByKey(WideString(sgPohCheck->Cells[2][i])) == 0)
{
// comServer->Edit();
// SetHeadValue("PohStop",1);
// comServer->Stop(1);
}
DelDetailObjFromGrid(sgPohCheck->Cells[2][i]);
sgPohCheck->Cells[1][i]="";
sgPohCheck->RemoveItem(i);
}
}
sgPodCheck->RowCount=1;
btnStop->Enabled=false;
}
//---------------------------------------------------------------------------
void __fastcall TfrmPohStop::sgPohCheckDblClick(TObject *Sender)
{
if(sgPohCheck->Row>0)
{
if(sgPohCheck->Cells[1][sgPohCheck->Row]==" ")
{
btnStop->Enabled=true;
sgPohCheck->Cells[1][sgPohCheck->Row]="√";
// AddDetailObjToGrid(sgPohCheck->Cells[2][ARow]);
}
else
{
sgPohCheck->Cells[1][sgPohCheck->Row]=" ";
// DelDetailObjFromGrid(sgPohCheck->Cells[2][ARow]);
//找到有没有需要审核的
for (int i=1;i<sgPohCheck->RowCount;i++)
{
if(sgPohCheck->Cells[1][i]=="√")
{
btnStop->Enabled=true;
break;
}
else
btnStop->Enabled=false;
}
}
}
}
//---------------------------------------------
void __fastcall TfrmPohStop::sgPohCheckClick(TObject *Sender)
{
if(sgPohCheck->RowCount > 1 && sgPohCheck->Row > 0)
{
AddDetailObjToGrid(sgPohCheck->Cells[2][sgPohCheck->Row]);
}
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?