Из действующего проекта. Вставка выбранных записей из одной таблицы в другую:
Код:
procedure TwPricemaking.kToPriceClick(Sender: TObject);
var
cRow:integer;
begin
if (gDetailing.SelectedRows.Count<0) then exit;
if GiPriceListId=null then exit;
{Перезапись выбранных столбцов в Price}
with gDetailing.DataSource.DataSet do
for cRow:=0 to gDetailing.SelectedRows.Count-1 do begin
GotoBookmark(pointer(gDetailing.SelectedRows.Items[cRow]));
iDetailID:=FieldByName('DETAIL_ID').AsInteger;
iLabourPrice:=FieldByName('LABOUR_COST').AsInteger;
sLongName:=FieldByName('DETAIL_LONGNAME').AsString;
iSeqence:=wPricing.hSpBase.Gen_Id('PRICE_SEQ',1);
wPricing.hrPrices.Append;
wPricing.hrPrices.FieldByName('PRICE_ID').AsInteger:=iSeqence;
wPricing.hrPrices.FieldByName('PRICELIST_ID').AsInteger:=GiPriceListId;
wPricing.hrPrices.FieldByName('DETAIL_ID').AsInteger:=iDetailID;
wPricing.hrPrices.FieldByName('LABOUR_PRICE').AsInteger:=iLabourPrice;
wPricing.hrPrices.FieldByName('DETAIL_LONGNAME').AsString:=sLongName;
end;
end;