📄 sogh_s_o.cpp
字号:
//---------------------------------------------------------------------------
void __fastcall TfrmSogh_S_O::RefreshGridData(int mAction)
{
AnsiString ItemStr;
switch(mAction)
{
case 0:
ItemStr="\t"+GetDetailValue(fiSogdLine)+"\t"+GetDetailValue(fiSogdSoCode)+"\t"+
GetDetailValue(fiSogdSodLine)+"\t"+GetDetailValue(fiSogdGoods)+"\t"+
GetDetailValue(fiSogdUnit)+"\t"+GetDetailValue(fiSogdPrice)+"\t"+
GetDetailValue(fiSogdQty)+"\t"+GetDetailValue(fiSogdAmt)+"\t"+
GetDetailValue(fiSogdTaxAmt)+"\t"+GetDetailValue(fiSogdDAmt);
sgSogd->AddItem(ItemStr);
break;
case 1:
ItemStr="\t"+GetDetailValue(fiSogdLine)+"\t"+GetDetailValue(fiSogdSoCode)+"\t"+
GetDetailValue(fiSogdSodLine)+"\t"+GetDetailValue(fiSogdGoods)+"\t"+
GetDetailValue(fiSogdUnit)+"\t"+GetDetailValue(fiSogdPrice)+"\t"+
GetDetailValue(fiSogdQty)+"\t"+GetDetailValue(fiSogdAmt)+"\t"+
GetDetailValue(fiSogdTaxAmt)+"\t"+GetDetailValue(fiSogdDAmt);
sgSogd->ChangeItem(ItemStr,sgSogd->Row);
break;
case 2:
sgSogd->RemoveItem(sgSogd->Row);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmSogh_S_O::DisplayBill()
{
if(comServer->RecordCount<1)
return;
GetDataFromComObject(1);
ChangeToBrowseState(true);
FillGridWithData();
}
//---------------------------------------------------------------------------
void __fastcall TfrmSogh_S_O::GetBill(AnsiString BillID)
{
if(comServer->Find("SoghCode='"+BillID+"'"))
{
DisplayBill();
}
else
if (ShowMessageWindow("在数据库中没有查到记录:"+BillID+",要增加吗?",mwsConfirmation)==IDYES)
{
AddHeadRecord();
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmSogh_S_O::FillGridWithData()
{
int i;
AnsiString ItemStr;
sgSogd->RowCount=1;
for (i=0;i<comServer->ItemCount;i++)
{
comServer->LocateItemByIndex(i);
RefreshGridData(0);
}
comServer->LocateItemByIndex(0);
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmSogh_S_O::GetHeadValue(int Index)
{
WideString S;
S = ReadFieldValue(comServer,Index);
return S;
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmSogh_S_O::GetDetailValue(int Index)
{
WideString S;
S = ReadItemValue(comServer,Index);
return S;
}
//---------------------------------------------------------------------------
void __fastcall TfrmSogh_S_O::SetHeadValue(int Index,AnsiString Value)
{
WriteFieldValue(comServer,Index,WideString(Value));
}
//---------------------------------------------------------------------------
void __fastcall TfrmSogh_S_O::SetDetailValue(int Index,AnsiString Value)
{
WriteItemValue(comServer,Index,WideString(Value));
}
//---------------------------------------------------------------------------
void __fastcall TfrmSogh_S_O::FormShow(TObject *Sender)
{
ClearControl(1,false);
ClearControl(2,false);
TGenBaseForm::MoveToFirst();
ChangeToBrowseState(true);
}
//---------------------------------------------------------------------------
void __fastcall TfrmSogh_S_O::sgSogdSelectCell(TObject *Sender, int ACol,
int ARow, bool &CanSelect)
{
if (ARow == 0)
{
return;
}
comServer->LocateItemByKey(WideString(sgSogd->TextMatrix[ARow][1]));
if (!comServer->Eof)
{
GetDataFromComObject(2);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmSogh_S_O::sgSogdDblClick(TObject *Sender)
{
int iRow;
iRow=sgSogd->Row;
if (iRow == 0)
{
return;
}
comServer->LocateItemByKey(WideString(sgSogd->TextMatrix[iRow][1]));
GetDataFromComObject(2);
sgSogd->Visible=false;
sgSogd->Align=alNone;
btnCancel->Enabled=true;
FloatPanel2->Visible=true;
FloatPanel2->Align=alClient;
}
//---------------------------------------------------------------------------
void __fastcall TfrmSogh_S_O::ChangeToBrowseState(bool Browse)
{
FloatPanel2->Visible=false;
FloatPanel2->Align=alNone;
btnOK->Enabled=false;
btnCancel->Enabled=false;
sgSogd->Visible=true;
sgSogd->Align=alClient;
}
//---------------------------------------------------------------------------
void __fastcall TfrmSogh_S_O::btnOKClick(TObject *Sender)
{
if ((CurrentState==caAddDetail)||(CurrentState==caAddBill))
{
try
{
if(DetailState==caAddDetail)
comServer->AddItem();
SendDataToComObject(2);
comServer->AddToObject();
ClearControl(2,false);
}
catch(Exception &e)
{
throw Exception(e.Message);
}
}
else
ChangeToBrowseState(false);
}
//---------------------------------------------------------------------------
void __fastcall TfrmSogh_S_O::btnCancelClick(TObject *Sender)
{
CancelChange();
}
//---------------------------------------------------------------------------
void __fastcall TfrmSogh_S_O::GenrateBill()
{
int TempCount;
TempCount = comServer->ItemCount;
StartWaitForm("正在启动生成界面");
TfrmSogd_S_O *p=new TfrmSogd_S_O(this);
try
{
p->GetComObject(comServer);
EndWaitForm();
p->ShowModal();
if (TempCount < comServer->ItemCount)
TGenBaseForm::SaveRecord();
else
CancelChange();
}
__finally
{
delete p;
}
}
void __fastcall TfrmSogh_S_O::seSogdQtyExit(TObject *Sender)
{
CalculateAmt();
}
//---------------------------------------------------------------------------
void __fastcall TfrmSogh_S_O::RefreshUpdateData(int MsgSrc,int MsgType)
{
AnsiString KeyCode;
switch(MsgSrc)
{
case euSdCurrency:
if(ShowUpdateMessage(MsgSrc,MsgType))
{
KeyCode=seSoghCurrency->ItemData[cbItem2];
AnsiString sSql;
sSql =AnsiString("select currencycode,currencyname,currencyrate=coalesce(rateratio,1),currencylocal from sdcurrency,sdrate");
sSql+=" where currencycode*=ratecurrency and ";
sSql+=" ratefmonth='"+g_sdSMonth+"'";
FillEdit(seSoghCurrency,sSql,"CurrencyName","CurrencyCode","CurrencyRate","CurrencyLocal");
seSoghCurrency->LocateKey(KeyCode);
}
break;
case euSdSsite:
if(ShowUpdateMessage(MsgSrc,MsgType))
{
KeyCode=seSoghSsite->ItemData[cbItem2];
FillEdit(seSoghSsite,"SELECT SsiteName,SsiteCode FROM sdSsite","SSiteName","SsiteCode");
seSoghSsite->LocateKey(KeyCode);
}
break;
case euSdSettleMode:
if(ShowUpdateMessage(MsgSrc,MsgType))
{
KeyCode=scSoghSettleMode->ItemData[cbItem2];
FillComboBox(scSoghSettleMode,"select settlemodename,settlemodecode from sdsettlemode order by settlemodename","settltModeName","SettleModeCode");
scSoghSettleMode->LocateKey(KeyCode);
}
break;
case euSdTax:
if(ShowUpdateMessage(MsgSrc,MsgType))
{
KeyCode=scSoghTaxCode->ItemData[cbItem2];
FillComboBox(scSoghTaxCode,"SELECT TaxName,TaxCode,TaxRate FROM sdTax order by TaxCode","TaxName","TaxCode","TaxRate");
scSoghTaxCode->LocateKey(KeyCode);
}
break;
case euSdPosType:
if(ShowUpdateMessage(MsgSrc,MsgType))
{
KeyCode=scSoghPosType->ItemData[cbItem2];
FillComboBox(scSoghPosType,"SELECT PosTypeCode,PosTypeName FROM sdPosType where postypeflg=2 order by PosTypeCode","PosTypeName","PosTypeCode");
scSoghPosType->LocateKey(KeyCode);
}
break;
case euSdDeliver:
if(ShowUpdateMessage(MsgSrc,MsgType))
{
KeyCode=scSoghDeliver->ItemData[cbItem2];
FillComboBox(scSoghDeliver,"SELECT DeliverName,DeliverCode FROM sdDeliver order by DeliverCode","DeliverName","DeliverCode");
scSoghDeliver->LocateKey(KeyCode);
}
break;
case euSdTransMode:
if(ShowUpdateMessage(MsgSrc,MsgType))
{
KeyCode=scSoghTransMode->ItemData[cbItem2];
FillComboBox(scSoghTransMode,"SELECT TransModeName,TransModeCode FROM sdTransMode order by TransModeCode","TransModeName","TransModeCode");
scSoghTransMode->LocateKey(KeyCode);
}
break;
case euSdClient:
if(ShowUpdateMessage(MsgSrc,MsgType))
{
KeyCode=seSoghClient->ItemData[cbItem2];
FillEdit(seSoghClient,"SELECT ClientName,ClientCode,ClientCurrency,ClientTaxCode FROM sdClient where ClientCancel=0","ClientName","ClientCode","ClientCurrency","ClientTaxCode");
seSoghClient->LocateKey(KeyCode);
}
break;
//Sogd
case euSdUnit:
if(ShowUpdateMessage(MsgSrc,MsgType))
{
KeyCode=seSogdUnit->ItemData[cbItem2];
FillEdit(seSogdUnit,"SELECT UnitCode,UnitName FROM sdUnit","Unitname","UnitCode");
seSogdUnit->LocateKey(KeyCode);
}
break;
case euSdLoc:
if(ShowUpdateMessage(MsgSrc,MsgType))
{
KeyCode=seSogdLoc->ItemData[cbItem2];
FillEdit(seSogdLoc,"select LocCode,LocName from sdLoc where Loctype=1 or loctype=4 order by LocCode","LocName","LocCode");
seSogdLoc->LocateKey(KeyCode);
}
break;
case euSdBatch:
if(ShowUpdateMessage(MsgSrc,MsgType))
{
KeyCode=seSogdBatch->ItemData[cbItem2];
FillEdit(seSogdBatch,"SELECT BatchCode,BatchDesc FROM sdBatch","BatchDesc","BatchCode");
seSogdBatch->LocateKey(KeyCode);
}
break;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -