📄 pickup.cpp
字号:
void __fastcall TfrmPickup::FillGridWithData()
{
int i;
AnsiString ItemStr;
sgPickup->RowCount=1;
for (i=0;i<comServer->ItemCount;i++)
{
comServer->LocateItemByIndex(i);
RefreshGridData(0);
}
RefreshStockupdGrid(scPickuphStockupCode->Text);
}
void __fastcall TfrmPickup::ChangeToBrowseState()
{
sgPickup->Visible=true;
sgStockupd->Visible=true;
FloatPanel2->Visible=false;
SetControlState(caSave);
sgPickup->SetFocus();
}
AnsiString __fastcall TfrmPickup::GetDetailValue(int FieldIndex)
{
WideString S;
S = ReadItemValue(comServer,FieldIndex);
return S;
}
AnsiString __fastcall TfrmPickup::GetHeadValue(int Index)
{
WideString S;
S = ReadFieldValue(comServer,Index);
return S;
}
void __fastcall TfrmPickup::SetHeadValue(int Index, AnsiString Value)
{
WriteFieldValue(comServer,Index,WideString(Value));
}
void __fastcall TfrmPickup::SetDetailValue(int Index, AnsiString Value)
{
comServer->SetItemValue(Index,WideString(Value));
}
void __fastcall TfrmPickup::FormShow(TObject *Sender)
{
InitEditControl();
ClearControl(1,false);
ClearControl(2,false);
TBillBaseForm::MoveToFirst();
ChangeToBrowseState();
}
//---------------------------------------------------------------------------
void __fastcall TfrmPickup::FormCreate(TObject *Sender)
{
FormIniFile="D:\Test.Ini";
SetGridWidth(Name,sgPickup,FormIniFile);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPickup::FormClose(TObject *Sender,
TCloseAction &Action)
{
TBillBaseForm::FormClose(Sender,Action);
WriteGridWidth(Name,sgPickup,FormIniFile);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPickup::sgPickupClick(TObject *Sender)
{
if (Row == 0)
{
return;
}
comServer->LocateItemByKey(WideString(sgPickup->TextMatrix[Row][1]));
if (!comServer->EOF)
{
GetDataFromComObject(2);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPickup::sgPickupDblClick(TObject *Sender)
{
int iRow;
iRow=sgPickup->Row;
if (iRow == 0)
{
return;
}
comServer->LocateItemByKey(WideString(sgPickup->TextMatrix[iRow][1]));
if (!comServer->EOF)
{
GetDataFromComObject(2);
sgPickup->Visible=false;
sgStockupd->Visible=false;
FloatPanel2->Visible=true;
}
SetControlState(caEditDetail);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPickup::btnOKClick(TObject *Sender)
{
sePickupdQtyExit(Sender);
if (CurrentState==caAddDetail)
{
comServer->AddItem();
SendDataToComObject(2);
comServer->AddToObject();
}
else if (CurrentState==caEditDetail)
{
SendDataToComObject(2);
}
// muSaveClick(Sender);
RefreshGridData(1);
RefreshStockupdGrid(scPickuphStockupCode->Text);
//ChangeToBrowseState();
}
//---------------------------------------------------------------------------
void __fastcall TfrmPickup::btnCancelClick(TObject *Sender)
{
ChangeToBrowseState();
}
//---------------------------------------------------------------------------
void __fastcall TfrmPickup::muEditDetailClick(TObject *Sender)
{
TBillBaseForm::muEditDetailClick(Sender);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPickup::RefreshStockupdGrid(AnsiString WhereStr)
{
TCOMIResultSet RsStockupd=NewResultSet();
AnsiString ItemStr;
RsStockupd->Open(WideString("select StockupdLine,StockupdSodLine,StockupdGoodsCode,")+
WideString("StockupdGoodsName=GoodsName,StockupdUnitCode,StockupdEnrate,")+
WideString("StockupdQty,StockupdPickupQty from SdStockupd,SdGoods ")+
WideString("where StockupdGoodsCode=GoodsCode and StockupdCode='")+
WhereStr+"'"+WideString(" order by StockupdLine"));
RsStockupd->MoveFirst();
sgStockupd->RowCount=1;
while( RsStockupd->EOF == 0 )
{
ItemStr="\t"+ReadColumnValueByName(RsStockupd,"StockupdLine")+"\t"+ReadColumnValueByName(RsStockupd,"StockupdSodLine")+"\t"
+ReadColumnValueByName(RsStockupd,"StockupdGoodsCode")+"\t"+ReadColumnValueByName(RsStockupd,"StockupdUnitCode")+"\t"
+ReadColumnValueByName(RsStockupd,"StockupdEnrate")+"\t"+ReadColumnValueByName(RsStockupd,"StockupdQty")+"\t"
+ReadColumnValueByName(RsStockupd,"StockupdPickupQty")+"\t"+ReadColumnValueByName(RsStockupd,"StockupdGoodsName");
sgStockupd->AddItem(ItemStr);
RsStockupd->MoveNext();
}
RsStockupd->Close();
}
//---------------------------------------------------------------------------
void __fastcall TfrmPickup::sgStockupdDblClick(TObject *Sender)
{
int iRow;
iRow=sgStockupd->Row;
AnsiString StockupValue=sgStockupd->TextMatrix[iRow][6];
AnsiString PickupValue=sgStockupd->TextMatrix[iRow][7];
if (iRow == 0)
{
return;
}
if(PickupValue.ToDouble()>=StockupValue.ToDouble())
{
ShowMessageWindow("该明细备货量已提完",mwsError);
return;
}
sgStockupd->Visible=false;
sgPickup->Visible=false;
FloatPanel2->Visible=true;
sePickupdLine->Text=IntToStr(comServer->ItemCount+1);
sePickupdStockupLine->Text= sgStockupd->TextMatrix[iRow][1];
sePickupdSodLine->Text=sgStockupd->TextMatrix[iRow][2];
sePickupdGoodsCode->Text=sgStockupd->TextMatrix[iRow][3];
sePickupdUnitCode->Text=sgStockupd->TextMatrix[iRow][4];
sePickupdEnrate->Text=sgStockupd->TextMatrix[iRow][5];
seStockupdQty->Text=sgStockupd->TextMatrix[iRow][6];
seStockupdPickupQty->Text=sgStockupd->TextMatrix[iRow][7];
sePickupdQty->Text=FloatToStr(seStockupdQty->Text.ToDouble()
-seStockupdPickupQty->Text.ToDouble());
sePickupdGoodsName->Text=sgStockupd->TextMatrix[iRow][8];
SetControlState(caAddDetail);//设为增加状态
}
//---------------------------------------------------------------------------
void __fastcall TfrmPickup::scPickuphStockupCodeExit(TObject *Sender)
{
RefreshStockupdGrid(scPickuphStockupCode->Text);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPickup::sePickupdQtyExit(TObject *Sender)
{
if((sePickupdQty->Text.ToDouble()<=0)||(sePickupdQty->Text.ToDouble()+seStockupdPickupQty->Text.ToDouble()-seStockupdQty->Text.ToDouble())>0)
{
ShowMessageWindow("需提数量不可能",mwsError);
sePickupdQty->SetFocus();
return;
}
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -