📄 zth.cpp
字号:
{
WideString S;
S = ReadFieldValue(comServer,Index);
return S;
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmZth::GetDetailValue(int Index)
{
WideString S;
S = ReadItemValue(comServer,Index);
return AnsiString(S);
}
//---------------------------------------------------------------------------
void __fastcall TfrmZth::SetHeadValue(int Index,AnsiString Value)
{
WriteFieldValue(comServer,Index,Value);
}
//---------------------------------------------------------------------------
void __fastcall TfrmZth::SetDetailValue(int Index,AnsiString Value)
{
WriteItemValue(comServer,Index,Value);
}
//---------------------------------------------------------------------------
void __fastcall TfrmZth::FormCreate(TObject *Sender)
{
// FormIniFile="D:\Test.Ini";
// SetGridWidth(Name,sgZth,FormIniFile);
}
//---------------------------------------------------------------------------
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);
if(seZtdPoCode->Enabled)
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::sgZthSelectCell(TObject *Sender, int ACol,
int ARow, bool &CanSelect)
{
if (ARow > 0)
{
comServer->LocateItemByKey(WideString(sgZth->TextMatrix[ARow][1]));
}
if (!comServer->Eof)
{
GetDataFromComObject(2);
}
}
//---------------------------------------------------------------------------
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(fiZtdLine); //收货单行号
ItemStr=ItemStr+"\t"+GetDetailValue(fiZtdPoCode); //采购单号
ItemStr=ItemStr+"\t"+GetDetailValue(fiZtdPodLine); //采购单行号
ItemStr=ItemStr+"\t"+GetDetailValue(fiZtdGoods); //物料编码
ItemStr=ItemStr+"\t"+GetDetailValue(fiZtdUnit); //计量单位
ItemStr=ItemStr+"\t"+GetDetailValue(fiZtdConvRate); //换算比率
ItemStr=ItemStr+"\t"+GetDetailValue(fiZtdQty); //在途数量
ItemStr=ItemStr+"\t"+GetDetailValue(fiZtdRecDate); //在途数量
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)
{
switch(MsgSrc)
{
case euSdSupply:
if(ShowUpdateMessage(MsgSrc,MsgType))
{
FillComboBox(scZthSupply,"Select SupplyCode,SupplyName FROM sdSupply where supplycancel=0 order by Supplycode","SupplyName","SupplyCode");
}
break;
case euSdUnit:
if(ShowUpdateMessage(MsgSrc,MsgType))
{
FillComboBox(scZtdUnit,"Select unitCode,UnitName FROM sdUnit","UnitName","UnitCode");
}
break;
default:
break;
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmZth::seZtdPoCodeButtonClick(TObject *Sender)
{
AnsiString SqlStr;
SqlStr="012[采购单号][行号][物料编码][计量单位][换算系数][采购数量][收货数][在途数][单价][需求日期][交货日期][发货日期]";
SqlStr+="select podcode,podline,podgoods,podunit,PodConvRate,PodQty,PodRQty,PodWQty,PodPrice,PodReqDate,PodRecDate,PodSendDate from sdpod,sdpoh where podcode=pohcode and pohcheck=1 and ";
SqlStr+=" podclose=0 and pohsupply='"+scZthSupply->ItemData[cbItem2]+"' 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(g_sdRsGoods->LocateByKey(WideString(seZtdGoods->Text))==0)
seZtdGoodsName->Text=GetGoodsValue("GoodsName");
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;
}
//---------------------------------------------------------------------------
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(fiZthCode))
{
comServer->LocateByKey(WideString(seZthCode->Text));
DisplayBill();
}
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -