uld.cpp
来自「一个以前收集的基于C/S架构的ERP客户端源代码」· C++ 代码 · 共 212 行
CPP
212 行
//---------------------------------------------------------------------------
#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, HWND chWnd, AnsiString MidCode,AnsiString WhereStr)
: TStdBaseForm(Owner,chWnd,MidCode,WhereStr)
{
btnOK->Enabled = false;
labUlhSupply->Caption = frmUlh->scUlhSupply->ItemData[0];
FUlhSupplyCode=frmUlh->scUlhSupply->ItemData[1];
FillGridWithData();
}
//--------------------------------------------------------------------------
__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("UldLine"));
UldLine ++;
}
else
UldLine = 1;
try
{
for (int k = 1; k < sgUlh->RowCount ;k++)
{
if (sgUlh->TextMatrix[k][1] != "√") continue;
comServer->AddItem();
comServer->DataSet->SetDetailValue("UldCode", frmUlh->seUlhCode->Text);
comServer->DataSet->SetDetailValue("UldLine", AnsiString(UldLine));
comServer->DataSet->SetDetailValue("UldPoCode", sgUlh->TextMatrix[k][2]); //采购单号
comServer->DataSet->SetDetailValue("UldPodLine",sgUlh->TextMatrix[k][3]); //采购单行号
comServer->DataSet->SetDetailValue("UldUrQty",sgUlh->TextMatrix[k][9]);
comServer->DataSet->SetDetailValue("UldDelay", sgUlh->TextMatrix[k][13]);
comServer->DataSet->SetDetailValue("UldStatus", "1");
comServer->DataSet->SetDetailValue("UldPoQty", sgUlh->TextMatrix[k][8]);
comServer->DataSet->SetDetailValue("UldGoods", sgUlh->TextMatrix[k][4]);
comServer->DataSet->SetDetailValue("Goodsname", sgUlh->TextMatrix[k][5]);
comServer->DataSet->SetDetailValue("GoodsSpec", sgUlh->TextMatrix[k][6]);
comServer->DataSet->SetDetailValue("UldPSite", sgUlh->TextMatrix[k][12]);
comServer->DataSet->SetDetailValue("UldUnit", sgUlh->TextMatrix[k][7]);
comServer->DataSet->SetDetailValue("UldRecDate", sgUlh->TextMatrix[k][10]);
comServer->DataSet->SetDetailValue("UldSendDate", sgUlh->TextMatrix[k][11]);
comServer->AddToObject();
UldLine++;
} // for
}
catch(Exception &e)
{
comServer->FreeItem();
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,goodsspec,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=new TComResultSet(Handle, g_ClientHandle);
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("GoodsSpec"); //货物名称
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::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 + =
减小字号Ctrl + -
显示快捷键?