📄 prech_p_i.cpp
字号:
{
if (Section ==1)
{
if(sePrechCode->Enabled)
sePrechCode->SetFocus();
}
else
{
sgPrech_P_I->Visible=false;
FloatPanel2->Visible=true;
pv_GoodsCode=sePrecdGoods->Text;
if(sePrecdLine->Enabled)
sePrecdLine->SetFocus();
}
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmPrech_P_I::GetDataToGrid()
{
AnsiString ItemStr;
ItemStr="\t"+GetDetailValue(fiPrecdLine)+
"\t"+GetDetailValue(fiPrecdGoods)+
"\t"+GetDetailValue(fiPrecdUnit)+
"\t"+GetDetailValue(fiPrecdQty)+
"\t"+GetDetailValue(fiPrecdDQty)+
"\t"+GetDetailValue(fiPrecdPo)+
"\t"+GetDetailValue(fiPrecdPodLine);
return ItemStr;
}
//---------------------------------------------------------------------------
void __fastcall TfrmPrech_P_I::RefreshGridData(int mAction)
{
int i;
AnsiString ItemStr=GetDataToGrid();
switch(mAction)
{
case 0:
sgPrech_P_I->AddItem(ItemStr);
break;
case 1:
i=sgPrech_P_I->Row;
sgPrech_P_I->ChangeItem(ItemStr,i);
break;
case 2:
sgPrech_P_I->RemoveItem(sgPrech_P_I->Row);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPrech_P_I::DisplayBill()
{
if(comServer->RecordCount<=0)
return;
GetDataFromComObject(1);
FillGridWithData();
}
//---------------------------------------------------------------------------
void __fastcall TfrmPrech_P_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_P_I::FillGridWithData()
{
AnsiString ItemStr;
sgPrech_P_I->RowCount=1;
if(comServer->RecordCount>0)
{
for (int i=0;i<comServer->ItemCount;i++)
{
comServer->LocateItemByIndex(i);
RefreshGridData(0);
}
}
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmPrech_P_I::GetHeadValue(int Index)
{
return ReadFieldValue(comServer,Index);
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmPrech_P_I::GetDetailValue(int Index)
{
return ReadItemValue(comServer,Index);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPrech_P_I::SetHeadValue(int Index,AnsiString Value)
{
WriteFieldValue(comServer,Index,Value);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPrech_P_I::SetDetailValue(int Index,AnsiString Value)
{
WriteItemValue(comServer,Index,Value);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPrech_P_I::FormCreate(TObject *Sender)
{
// FormIniFile="D:\Test.Ini";
// SetGridWidth(Name,sgPrech_P_I,FormIniFile);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPrech_P_I::FormClose(TObject *Sender,
TCloseAction &Action)
{
TGenBaseForm::FormClose(Sender,Action);
// WriteGridWidth(Name,sgPrech_P_I,FormIniFile);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPrech_P_I::FormShow(TObject *Sender)
{
ClearControl(1,false);
ClearControl(2,false);
ChangeToBrowseState();
TGenBaseForm::MoveToFirst();
}
//---------------------------------------------------------------------------
void __fastcall TfrmPrech_P_I::ChangeToBrowseState(bool Browse)
{
sgPrech_P_I->Visible = true;
FloatPanel2->Visible = false;
if(Browse == false)
sgPrech_P_I->SetFocus();
}
//---------------------------------------------------------------------------
void __fastcall TfrmPrech_P_I::sgPrech_P_IDblClick(TObject *Sender)
{
int iRow;
iRow=sgPrech_P_I->Row;
if (iRow == 0)
{
return;
}
sgPrech_P_I->Visible=false;
FloatPanel2->Visible=true;
}
//---------------------------------------------------------------------------
void __fastcall TfrmPrech_P_I::btnOKClick(TObject *Sender)
{
try
{
if(CurrentState==caAddBill || CurrentState==caAddDetail)
{
if(DetailState==caAddDetail)
comServer->AddItem();
SendDataToComObject(2);
comServer->AddToObject();
ClearControl(2,false);
if(sePrecdPodLine->Enabled)
sePrecdPodLine->SetFocus();
}
else
ChangeToBrowseState();
}
catch(Exception &e)
{
throw Exception(e.Message);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPrech_P_I::btnCancelClick(TObject *Sender)
{
CancelChange();
}
//---------------------------------------------------------------------------
void __fastcall TfrmPrech_P_I::sgPrech_P_ISelectCell(TObject *Sender,
int ACol, int ARow, bool &CanSelect)
{
if(CurrentState==caNormal)
{
if (ARow > 0)
{
AnsiString KeyStr=sgPrech_P_I->TextMatrix[ARow][1];
comServer->LocateItemByKey(WideString(KeyStr));
}
if (!comServer->Eof)
GetDataFromComObject(2);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPrech_P_I::GenrateBill()
{
int TempCount;
TempCount = comServer->ItemCount;
StartWaitForm("正在启动生成界面");
TfrmPrecd_P_I *p=new TfrmPrecd_P_I(this);
try
{
p->GetComObject(comServer);
EndWaitForm();
p->ShowModal();
if (TempCount < comServer->ItemCount)
TGenBaseForm::SaveRecord();
else
CancelChange();
}
__finally
{
delete p;
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPrech_P_I::FillLineData()
{
//根据采购订单,填充行号
// AnsiString sSql;
// if(CurrentState == caNormal) //浏览状态下允许查看被结清的采购单行
// sSql=AnsiString("select ltrim(str(PodLine))+'-'+PodGoods memo,PodLine from sdPod where PodCode='"+sePrecdPo->Text+"' order by podline");
// else
// sSql=AnsiString("select ltrim(str(PodLine))+'-'+PodGoods memo,PodLine from sdPod where PodCode='"+sePrechPo->Text+"' and podClose =0 order by podline");
}
//---------------------------------------------------------------------------
void __fastcall TfrmPrech_P_I::scPrecdUnitClick(TObject *Sender)
{
/*
if(scPrecdUnit->ItemIndex > -1)
{
sePrecdConv->Text=scPrecdUnit->ItemData[2];
}
*/
}
//---------------------------------------------------------------------------
void __fastcall TfrmPrech_P_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))
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -