F_Unit:=FDMemTable2 FieldByName (' F_Unit). AsString;
FDMemTable2. Append;
FDMemTable2. FieldByName (' the F_Type '). The Value:=the F_Type;
FDMemTable2. FieldByName (' F_Unit '). The Value:=F_Unit;
This is a manual
I want to according to the database, which fields can copy line copy current line
With FDMemTable1 do
The begin
While not Eof do
The begin
If DBGridEh1. FieldColumns [FieldByName (' F_field). The Value]. DisplayText<> "' then
The F_Type:=DBGridEh1. FieldColumns [FieldByName (' F_field). The Value]. DisplayText;
next;
FDMemTable2. Append;
FDMemTable2. FieldByName (' F_Color '). The Value:=the F_Type;
end;
end;
Like this
CodePudding user response:
According to the configuration copy current line, his topCodePudding user response:
Is essentially duplicate data set, the current row data, because the relationship between the field type, should be in the form of a string, save field data, the number of fields at the same time, double is variable,Because, copy of such data, the use of a character array is better, will be the value of the various fields, in the array, when need to read it again,
CodePudding user response:
Procedure CopyData (FrData, ToData: TDataSet; NotCopyField: String; Action: String; IsPost: Boolean; IsCopySysField: Boolean=False);Var I: integer;
StrList: TStringList;
The begin
If not (Todata. State in [dsEdit dsInsert]) then
The begin
If the Action='I' then
ToData. Insert
The else
If the Action='E' then
ToData. Edit
end;
StrList:=TStringList. Create;
If not isCopySysField then
The begin
StrList. Add (' CMCD);
StrList. Add (" CREATEBY ");
StrList. Add (" CREATEDT ");
StrList. Add (' EDITBY ');
StrList. Add (' EDITDT ');
StrList. Add (' APPROVALBY ');
StrList. Add (' APPROVALDT ');
StrList. Add (' STATUSFLAG ');
StrList. Add (" REVISION ");
end;
Crlst (StrList NotCopyField);
Try
For I:=0 to Todata. Do FieldCount - 1
The begin
If (Todata Fields [I] DataType & lt;> FtAutoInc) and
(Todata. Fields [I] FieldKind=fkData) and
(StrList IndexOf (ToData Fields [I] FieldName)=1) and
(Frdata. Fields. FindField (Todata Fields [I] FieldName) & lt;> Nil) then
The begin
If not Frdata. Fields. FindField (Todata Fields [I] FieldName). The IsNull then
Todata. Fields [I] Value:=Frdata. Fields. FindField (Todata. Fields [I] FieldName). The Value
The else
Todata. Fields [I]. The Clear;
end;
end;
If isPost then
Todata. Post;
The Finally
StrList. Free;
end;
end;
This way can not
CodePudding user response:
VarArr: array [0.. 10] of string;
I: integer;
The begin
Arr [0] :=FDMemTable1 Fields. [0] AsString;
Arr [1] :=FDMemTable1 Fields [1]. The AsString;
Arr [2] :=FDMemTable1 Fields. [2] AsString;
Arr [3] :=FDMemTable1 Fields. [3] AsString;
FDMemTable1. Append;
FDMemTable1. Fields [0]. AsString:=arr [0];
FDMemTable1. Fields [1]. AsString:=arr [1].
FDMemTable1. Fields [2]. AsString:=arr [2].
FDMemTable1. Fields [3]. AsString:=arr [3].
end;
This way also not line
But we also don't know how many lines, so I can use to replace the inside of the array number, I is the serial number field
CodePudding user response:
Get a temporary data set (update model with batch updates, the purpose is not to submit data to the database), copy of the source data cloning directly to the temporary data set in the current record,Paste, from the temporary data sets can be inserted into the target data set,
CodePudding user response: