📄 prech_n_i.cpp
字号:
{
if (Section ==1)
{
if(sePrechCode->Enabled)
sePrechCode->SetFocus();
}
else
{
sgPrech_N_I->Visible=false;
FloatPanel2->Visible=true;
pv_GoodsCode=sePrecdGoods->Text;
if(sePrecdLine->Enabled)
sePrecdLine->SetFocus();
SetDetail(sePrecdGoods->Text);
}
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmPrech_N_I::GetDataToGrid()
{
AnsiString ItemStr;
ItemStr="\t"+GetDetailValue(fiPrecdLine)+
"\t"+GetDetailValue(fiPrecdGoods)+
"\t"+GetDetailValue(fiPrecdUnit)+
"\t"+GetDetailValue(fiPrecdQty)+
"\t"+GetDetailValue(fiPrecdDQty)+
"\t"+GetDetailValue(fiPrecdPrice)+
"\t"+GetDetailValue(fiPrecdAmt);
return ItemStr;
}
//---------------------------------------------------------------------------
void __fastcall TfrmPrech_N_I::RefreshGridData(int mAction)
{
int i;
AnsiString ItemStr=GetDataToGrid();
switch(mAction)
{
case 0:
sgPrech_N_I->AddItem(ItemStr);
break;
case 1:
i=sgPrech_N_I->Row;
sgPrech_N_I->ChangeItem(ItemStr,i);
break;
case 2:
sgPrech_N_I->RemoveItem(sgPrech_N_I->Row);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPrech_N_I::DisplayBill()
{
if(comServer->RecordCount<=0)
return;
GetDataFromComObject(1);
FillGridWithData();
}
//---------------------------------------------------------------------------
void __fastcall TfrmPrech_N_I::GetBill(AnsiString BillID)
{
int iRow;
iRow=comServer->Find("PrechCode='"+BillID+"'");
if (iRow>0) //FIND THIS BILL
{
DisplayBill();
}
else
if (ShowMessageWindow("在数据库中没有查到记录:"+BillID+",要增加吗?",mwsConfirmation)==IDYES)
{
AddHeadRecord();
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPrech_N_I::FillGridWithData()
{
AnsiString ItemStr;
sgPrech_N_I->RowCount=1;
if(comServer->RecordCount>0)
{
for (int i=0;i<comServer->ItemCount;i++)
{
comServer->LocateItemByIndex(i);
RefreshGridData(0);
}
}
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmPrech_N_I::GetHeadValue(int Index)
{
return ReadFieldValue(comServer,Index);
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmPrech_N_I::GetDetailValue(int Index)
{
return ReadItemValue(comServer,Index);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPrech_N_I::SetHeadValue(int Index,AnsiString Value)
{
WriteFieldValue(comServer,Index,Value);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPrech_N_I::SetDetailValue(int Index,AnsiString Value)
{
WriteItemValue(comServer,Index,Value);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPrech_N_I::FormCreate(TObject *Sender)
{
// FormIniFile="D:\Test.Ini";
// SetGridWidth(Name,sgPrech_N_I,FormIniFile);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPrech_N_I::FormClose(TObject *Sender,
TCloseAction &Action)
{
TGenBaseForm::FormClose(Sender,Action);
// WriteGridWidth(Name,sgPrech_N_I,FormIniFile);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPrech_N_I::FormShow(TObject *Sender)
{
ClearControl(1,false);
ClearControl(2,false);
ChangeToBrowseState();
TGenBaseForm::MoveToFirst();
}
//---------------------------------------------------------------------------
void __fastcall TfrmPrech_N_I::ChangeToBrowseState(bool Browse)
{
sgPrech_N_I->Visible = true;
FloatPanel2->Visible = false;
if(Browse == false)
sgPrech_N_I->SetFocus();
}
//---------------------------------------------------------------------------
void __fastcall TfrmPrech_N_I::sgPrech_N_IDblClick(TObject *Sender)
{
int iRow;
iRow=sgPrech_N_I->Row;
if (iRow == 0)
{
return;
}
sgPrech_N_I->Visible=false;
FloatPanel2->Visible=true;
}
//---------------------------------------------------------------------------
void __fastcall TfrmPrech_N_I::btnOKClick(TObject *Sender)
{
try
{
if(CurrentState==caAddBill || CurrentState==caAddDetail)
{
if(DetailState==caAddDetail)
comServer->AddItem();
SendDataToComObject(2);
comServer->AddToObject();
ClearControl(2,false);
if(sePrecdGoods->Enabled)
sePrecdGoods->SetFocus();
}
else
ChangeToBrowseState();
}
catch(Exception &e)
{
throw Exception(e.Message);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPrech_N_I::btnCancelClick(TObject *Sender)
{
CancelChange();
}
//---------------------------------------------------------------------------
void __fastcall TfrmPrech_N_I::sgPrech_N_ISelectCell(TObject *Sender,
int ACol, int ARow, bool &CanSelect)
{
if(CurrentState==caNormal)
{
if (ARow > 0)
{
AnsiString KeyStr=sgPrech_N_I->TextMatrix[ARow][1];
comServer->LocateItemByKey(WideString(KeyStr));
}
if (!comServer->Eof)
GetDataFromComObject(2);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPrech_N_I::RefreshUpdateData(int MsgSrc,int MsgType)
{
switch(MsgSrc)
{
case euSdFc:
scPrechFmonth->Text=g_sdPMonth;
break;
case euSdPosType:
if(ShowUpdateMessage(MsgSrc,MsgType))
{
FillComboBox(scPrechPosType,"SELECT PosTypeCode,PosTypeName FROM sdPosType where Postypeflg=1 order by PosTypeCode",
"PosTypeName","PosTypeCode");
}
break;
case euSdSupply:
if(ShowUpdateMessage(MsgSrc,MsgType))
{
FillComboBox(scPrechSupply,"SELECT SupplyCode,SupplyName FROM sdSupply where supplycancel=0 order by SupplyCode",
"SupplyName","SupplyCode");
}
break;
case euSdCurrency:
if(ShowUpdateMessage(MsgSrc,MsgType))
{
AnsiString sSql;
sSql =AnsiString("select currencycode,currencyname,currencyrate=coalesce(rateratio,1),currencylocal from sdcurrency,sdrate");
sSql+=" where currencycode*=ratecurrency and ";
sSql+=" ratefmonth='"+g_sdPMonth+"'";
FillEdit(sePrechCurrency,sSql,"CurrencyName","CurrencyCode","currencyrate","currencylocal");
}
break;
case euSdTax:
if(ShowUpdateMessage(MsgSrc,MsgType))
{
FillComboBox(scPrechTaxCode,"SELECT TaxCode,TaxName,TaxRate FROM sdTax order by TaxCode","TaxName","TaxCode","TaxRate");
}
break;
case euSdSettleMode:
if(ShowUpdateMessage(MsgSrc,MsgType))
{
FillComboBox(scPrechSettleMode,"SELECT SettleModeCode,SettleModeName FROM sdSettleMode order by SettleModeCode",
"SettleModeName","SettleModeCode");
}
break;
case euSdDeliver:
if(ShowUpdateMessage(MsgSrc,MsgType))
{
FillComboBox(scPrechDeliver,"SELECT DeliverCode,DeliverName FROM sdDeliver order by DeliverCode",
"DeliverName","DeliverCode");
}
break;
case euSdTransMode:
if(ShowUpdateMessage(MsgSrc,MsgType))
{
FillComboBox(scPrechTransMode,"SELECT TransModeCode,TransModeName FROM sdTransMode order by TransModeCode",
"TransModeName","TransModeCode");
}
break;
case euSdPsite:
if(ShowUpdateMessage(MsgSrc,MsgType))
{
FillEdit(sePrechPsite,"SELECT PsiteCode,PsiteName FROM sdPsite order by PsiteCode",
"PsiteName","PsiteCode");
}
break;
case euSdUnit:
if(ShowUpdateMessage(MsgSrc,MsgType))
{
FillEdit(sePrecdUnit,"SELECT UnitName memo,UnitCode,UnitRate FROM sdUnit Order by UnitCode","Memo","UnitCode","UnitRate");
}
break;
case euSdLoc:
if(ShowUpdateMessage(MsgSrc,MsgType))
{
if(g_sdQuality == false) //无需质量管理
FillEdit(sePrecdLoc,"select LocCode,LocName from sdLoc where LocType=1 order by locCode","LocName","LocCode");
else //需要质量管理
FillEdit(sePrecdLoc,"select LocCode,LocName from sdLoc where LocType=3 order by loccode","LocName","LocCode");
}
break;
case euSdBatch:
if(ShowUpdateMessage(MsgSrc,MsgType))
{
FillComboBox(scPrecdBatch,"SELECT BatchCode,BatchDesc FROM sdBatch order by BatchCode","BatchDesc","BatchCode");
}
break;
default:
break;
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPrech_N_I::sePrecdAmtExit(TObject *Sender)
{
/*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -