📄 uld.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Uld.h"
#include "Ulh.h"
#pragma link "fpanel"
#pragma link "SDEdit"
#pragma link "SDGrid"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "fpanel"
#pragma link "SDEdit"
#pragma link "SDGrid"
#pragma link "SDComboBox"
#pragma resource "*.dfm"
//---------------------------------------------------------------------------
__fastcall TfrmUld::TfrmUld(TComponent* Owner)
: TStdBaseForm(Owner)
{
btnOK->Enabled = false;
labUlhSupply->Caption = frmUlh->scUlhSupply->ItemData[0];
FUlhSupplyCode=frmUlh->scUlhSupply->ItemData[1];
FillGridWithData();
}
//--------------------------------------------------------------------------
void __fastcall TfrmUld::btnOKClick(TObject *Sender)
{
int UldLine, i;
int ErrNum;
try
{
StartWaitForm("正在生成催货单,请稍候...");
if(sgUlh->RowCount>1)
{
i = comServer->ItemCount;
if(i > 0)
{
comServer->LocateItemByIndex(i-1);
UldLine = StrToInt(frmUlh->GetDetailValue(fiUldLine));
UldLine ++;
}
else
UldLine = 1;
try
{
for (int k = 1; k < sgUlh->RowCount ;k++)
{
if (sgUlh->TextMatrix[k][1] != "√") continue;
comServer->AddItem();
SetDetailValue(fiUldCode, frmUlh->seUlhCode->Text);
SetDetailValue(fiUldLine, AnsiString(UldLine));
SetDetailValue(fiUldPoCode, sgUlh->TextMatrix[k][2]); //采购单号
SetDetailValue(fiUldPodLine,sgUlh->TextMatrix[k][3]); //采购单行号
SetDetailValue(fiUldUrQty,sgUlh->TextMatrix[k][8]);
SetDetailValue(fiUldDelay, sgUlh->TextMatrix[k][12]);
SetDetailValue(fiUldStatus, "1");
comServer->AddToObject();
UldLine++;
} // for
}
catch(Exception &e)
{
comServer->Cancel();
this->ModalResult=0;
throw Exception(e.Message);
}
}
}
__finally
{
EndWaitForm();
}
Close();
}
//---------------------------------------------------------------------------
void __fastcall TfrmUld::btnCancelClick(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
void __fastcall TfrmUld::FillGridWithData()
{
AnsiString ItemStr;
TComResultSet *pRst;
AnsiString m_Sql;
m_Sql="select podcode,podline,podgoods,goodsName,podunit,PodQty,PodUrQty=PodQty-PodRQty+PodBQty,PodRecDate,PodSendDate,pohpsite,poddelay=datediff(day,podrecdate,getdate()) from sdpod,sdpoh,sdgoods where podcode=pohcode and pohcheck=1 and ";
m_Sql+=" goodscode=podgoods and podclose=0 and pohclose=0 and pohsupply='"+FUlhSupplyCode+"' and podrecdate<='"+g_sdCurDate+"' order by pohdate desc,pohcode,PodLine ";
try
{
StartWaitForm("正在查询数据,请稍候......");
pRst=NewResultSet();
pRst->Open(m_Sql,"");
pRst->MoveFirst();
sgUlh->RowCount = 1;
while( pRst->Eof == 0)
{
ItemStr="\t\t" + pRst->FieldByName("PodCode"); //采购单号
ItemStr=ItemStr+"\t"+pRst->FieldByName("PodLine"); //采购单行号
ItemStr=ItemStr+"\t"+pRst->FieldByName("PodGoods"); //货物编码
ItemStr=ItemStr+"\t"+pRst->FieldByName("GoodsName"); //货物名称
ItemStr=ItemStr+"\t"+pRst->FieldByName("PodUnit"); //单位
ItemStr=ItemStr+"\t"+pRst->FieldByName("PodQty"); //采购数量
ItemStr=ItemStr+"\t"+pRst->FieldByName("PodUrQty");
ItemStr=ItemStr+"\t"+pRst->FieldByName("PodRecDate"); // 交货日期
ItemStr=ItemStr+"\t"+pRst->FieldByName("PodSendDate");
ItemStr=ItemStr+"\t"+pRst->FieldByName("PohPsite");
ItemStr=ItemStr+"\t"+pRst->FieldByName("PodDelay");
sgUlh->AddItem(ItemStr);
pRst->MoveNext();
}
pRst->Close();
}
__finally
{
EndWaitForm();
}
delete pRst;
}
//---------------------------------------------------------------------------
void __fastcall TfrmUld::GetComObject(TComServer *comServerPtr)
{
comServer = comServerPtr;
}
//---------------------------------------------------------------------------
void __fastcall TfrmUld::SetDetailValue(int Index,AnsiString Value)
{
WriteItemValue(comServer,Index,Value);
}
//---------------------------------------------------------------------------
void __fastcall TfrmUld::sgUlhDblClick(TObject *Sender)
{
int ARow=sgUlh->Row;
if(ARow<1)
return;
if(sgUlh->Col==1)
{
if (sgUlh->TextMatrix[ARow][1] == "√")
{
sgUlh->Cells[1][ARow] = "";
for (int i=1;i<sgUlh->RowCount;i++)
{
if(sgUlh->Cells[1][i]=="√")
{
btnOK->Enabled=true;
break;
}
else
btnOK->Enabled=false;
}
}
else
{
sgUlh->TextMatrix[ARow][1] = "√";
btnOK->Enabled = true;
}
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmUld::bbSelAllClick(TObject *Sender)
{
if(sgUlh->RowCount <= 1)
return;
for(int i=1;i<sgUlh->RowCount;i++)
sgUlh->Cells[1][i] = "√";
btnOK->Enabled = true;
}
//---------------------------------------------------------------------------
void __fastcall TfrmUld::bbSelNoneClick(TObject *Sender)
{
for(int i=1;i<sgUlh->RowCount;i++)
sgUlh->Cells[1][i] = "";
btnOK->Enabled = false;
}
//---------------------------------------------------------------------------
void __fastcall TfrmUld::sgUlhSelectCell(TObject *Sender, int ACol,
int ARow, bool &CanSelect)
{
if(sgUlh->Cells[1][ARow]=="√")
sgUlh->ReadOnly=false;
else
sgUlh->ReadOnly=true;
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -