zth.cpp
来自「一个以前收集的基于C/S架构的ERP客户端源代码」· C++ 代码 · 共 560 行 · 第 1/2 页
CPP
560 行
Variant vTmp;
vTmp=comServer->DataSet->GetItemValue(fieldname);
if(vTmp.IsNull())
return "";
else
return AnsiString(vTmp);
}
//---------------------------------------------------------------------------
void __fastcall TfrmZth::SetHeadValue(AnsiString fieldname,AnsiString Value)
{
comServer->DataSet->SetMasterValue(fieldname,Value);
}
//---------------------------------------------------------------------------
void __fastcall TfrmZth::SetDetailValue(AnsiString fieldname,AnsiString Value)
{
comServer->DataSet->SetDetailValue(fieldname,Value);
}
//---------------------------------------------------------------------------
void __fastcall TfrmZth::FormShow(TObject *Sender)
{
ClearControl(1,false);
ClearControl(2,false);
ChangeToBrowseState();
TGenBaseForm::MoveToFirst();
}
//---------------------------------------------------------------------------
void __fastcall TfrmZth::ChangeToBrowseState(bool Browse)
{
sgZth->Visible = true;
FloatPanel2->Visible = false;
if(Browse == false)
sgZth->SetFocus();
}
//---------------------------------------------------------------------------
void __fastcall TfrmZth::btnOKClick(TObject *Sender)
{
try
{
if ((CurrentState==caAddDetail)||(CurrentState==caAddBill))
{
if(DetailState==caAddDetail)
comServer->AddItem();
SendDataToComObject(2);
comServer->AddToObject();
ClearControl(2,false);
seZtdPoCode->SetFocus();
}
else
ChangeToBrowseState();
}
catch(Exception &e)
{
throw Exception(e.Message);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmZth::btnCancelClick(TObject *Sender)
{
CancelChange();
}
//---------------------------------------------------------------------------
void __fastcall TfrmZth::WaitUserInput(int Section)
{
if (Section ==1)
{ // Head
if (CurrentState == caEditHead)
deZthDate->SetFocus();
else
{
if(seZthCode->Enabled)
seZthCode->SetFocus();
}
}
else
{ // Detail
if (CurrentState == caAddBill || CurrentState == caAddDetail)
{
ClearControl(2, false);
}
sgZth->Visible=false;
FloatPanel2->Visible=true;
if(seZtdPoCode->Enabled)
seZtdPoCode->SetFocus();
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmZth::sgZthDblClick(TObject *Sender)
{
int iRow;
iRow=sgZth->Row;
if (iRow == 0)
{
return;
}
sgZth->Visible=false;
FloatPanel2->Visible=true;
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmZth::GetDataToGrid()
{
AnsiString ItemStr;
ItemStr="\t"+GetDetailValue("ZtdLine"); //收货单行号
ItemStr=ItemStr+"\t"+GetDetailValue("ZtdPoCode"); //采购单号
ItemStr=ItemStr+"\t"+GetDetailValue("ZtdPodLine"); //采购单行号
ItemStr=ItemStr+"\t"+GetDetailValue("ZtdGoods"); //物料编码
ItemStr=ItemStr+"\t"+GetDetailValue("Goodsname"); //物料名称
ItemStr=ItemStr+"\t"+GetDetailValue("Goodsspec"); //类型
ItemStr=ItemStr+"\t"+GetDetailValue("ZtdUnit"); //计量单位
ItemStr=ItemStr+"\t"+GetDetailValue("ZtdConvRate"); //换算比率
ItemStr=ItemStr+"\t"+GetDetailValue("ZtdQty"); //在途数量
ItemStr=ItemStr+"\t"+GetDetailValue("ZtdRecDate"); //在途数量
return ItemStr;
}
//---------------------------------------------------------------------------
void __fastcall TfrmZth::GenrateBill()
{
int TempCount;
TempCount = comServer->ItemCount;
TfrmZtd *p;
p = new TfrmZtd(this);
p->GetComObject(comServer);
try
{
p->ShowModal();
}
__finally
{
//delete p;
}
if (TempCount < comServer->ItemCount)
TGenBaseForm::SaveRecord();
else
CancelChange();
}
//---------------------------------------------------------------------------
void __fastcall TfrmZth::RefreshUpdateData(int MsgSrc,int MsgType)
{
}
//---------------------------------------------------------------------------
void __fastcall TfrmZth::seZtdPoCodeButtonClick(TObject *Sender)
{
l_Query->Close();
l_Query->Open("select goodsname,goodscode,goodsspec from sdgoods","goodscode");
AnsiString SqlStr;
TComResultSet * TempRes = new TComResultSet(Handle,g_ClientHandle);
TempRes->Open("select parametercode,parametervalue from sdparameter where parametercode ='10302' and parametervalue =1","parametercode");
SqlStr="012[采购单号][行号][物料编码][计量单位][换算系数][采购数量][收货数量][在途数][单价][需求日期][交货日期][发货日期]";
SqlStr+="select podcode,podline,podgoods,podunit,PodConvRate,PodQty,PodRQty,PodWQty,PodPrice,PodReqDate,PodRecDate,PodSendDate,goodsbuyer,goodscode from sdpod,sdpoh,sdgoods where podcode=pohcode and pohcheck=1 and ";
SqlStr+="podgoods=goodscode and podclose=0 and pohsupply='"+scZthSupply->ItemData[cbItem2]+"'";
if(TempRes->RecordCount >0)
SqlStr+=" and goodsbuyer = '"+g_sdUserCode+"'";
SqlStr+=" order by pohdate desc";
TfrmWnQuery *p;
try
{
StartWaitForm("正在查询,请稍候...");
p=new TfrmWnQuery(this,"采购单查询",SqlStr);
}
__finally
{
EndWaitForm();
}
if(p->ShowModal()==mrOk)
{
seZtdPoCode->Text=p->ColData[1];
seZtdPodLine->Text=p->ColData[2];
seZtdGoods->Text=p->ColData[3];
scZtdUnit->LocateKey(p->ColData[4]);
seZtdConvRate->Text=p->ColData[5];
if(seZtdGoods->Text != "")
if(l_Query->LocateByKey(seZtdGoods->Text)==0)
seZtdGoodsName->Text=l_Query->FieldByName("GoodsName");
GoodsSpec->Text=l_Query->FieldByName("Goodsspec");
seZtdRQty->Text=p->ColData[7];
seZtdPrice->Text=p->ColData[9];
deZtdReqDate->Text=p->ColData[10];
deZtdRecDate->Text=p->ColData[11];
deZtdSendDate->Text=p->ColData[12];
}
delete p;
delete TempRes;
}
//---------------------------------------------------------------------------
void __fastcall TfrmZth::seZtdQtyButtonClick(TObject *Sender)
{
AnsiString SqlStr;
SqlStr="008[采购单号][行号][物料编码][计量单位][换算系数][采购数量][收货数][在途数]";
SqlStr+="select podcode,podline,podgoods,podunit,PodConvRate,PodQty,PodRQty,PodWQty from sdpod where podcode='"+seZtdPoCode->Text+"' and ";
SqlStr+="podLine="+seZtdPodLine->Text;
TfrmWnQuery *p;
try
{
StartWaitForm("正在查询,请稍候...");
p=new TfrmWnQuery(this,"采购单查询",SqlStr);
}
__finally
{
EndWaitForm();
}
p->ShowModal();
delete p;
}
//---------------------------------------------------------------------------
void __fastcall TfrmZth::seZthCodeExit(TObject *Sender)
{
if(CurrentState==caNormal && seZthCode->Text != GetHeadValue("ZthCode"))
{
comServer->LocateByKey(WideString(seZthCode->Text));
DisplayBill();
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmZth::FormClose(TObject *Sender, TCloseAction &Action)
{
TGenBaseForm::FormClose(Sender, Action);
}
//---------------------------------------------------------------------------
bool __fastcall TfrmZth::BeforeCheck()
{
SetHeadValue("ZthCheck",1);
SetHeadValue("ZthChecker",g_sdUserCode);
SetHeadValue("ZthCheckDate",g_sdCurDate);
return true;
}
//---------------------------------------------------------------------------
bool __fastcall TfrmZth::BeforeUnCheck()
{
SetHeadValue("ZthCheck",0);
SetHeadValue("ZthChecker",g_sdUserCode);
SetHeadValue("ZthCheckDate",g_sdCurDate);
return true;
}
//---------------------------------------------------------------------------
void __fastcall TfrmZth::sgZthClick(TObject *Sender)
{
if (sgZth->Row > 0)
{
comServer->LocateItemByKey(WideString(sgZth->TextMatrix[sgZth->Row][1]+"\t"+seZthCode->Text));
GetDataFromComObject(2);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmZth::SupplyCodeButtonButtonClick(TObject *Sender)
{
if(OpenSupplyForm("")==true)
{
scZthSupply->LocateKey(GetSupplyValue(gtOpenForm,"SupplyCode"));
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmZth::scZthSupplyExit(TObject *Sender)
{
TComResultSet * TempRes = new TComResultSet(Handle,g_ClientHandle);
TempRes->Open("select parametercode,parametervalue from sdparameter where parametercode = '10302' and parametervalue =1","parametercode");
if(TempRes->RecordCount > 0)
{
TempRes->Close();
TempRes->Open("select supplycode,supplyname,supplybuyer from sdsupply where supplybyuer ='"+g_sdUserCode+"' and supplycode ='"+scZthSupply->Text+"' or supplyname = '"+scZthSupply->Text+"'","supplycode");
}
else
{
TempRes->Close();
TempRes->Open("select supplycode,supplyname,supplybuyer from sdsupply where supplycode = '"+scZthSupply->Text+"' or supplyname = '"+scZthSupply->Text+"'", "supplycode");
}
if(scZthSupply->LocateKey(TempRes->FieldByName("supplycode"))==0)
{
scZthSupply->ItemIndex =-1;
}
delete TempRes;
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?