Home > Back-end >  Use cxGrid cross-border
Use cxGrid cross-border

Time:09-22

With cxgrid traversal modify data, is to use ado of eof, and cxGrid1DBTableView1 DataController. IsEOF, cxGrid1DBTableView1. Controller. FocusedRow. IsLast to determine whether or not to take, but crossing the line, please you see
greatly
 
Procedure TfrmBatchExtend. SbtnExtendClick (Sender: TObject);
Var
RowIndex: Integer;
Q: TADOQuery;
SDate, sName, s: a string;
F: TIniFile;
The begin
If (eExtend. Text='0') or (eExtend. Text=' ') then
The begin
ShowMessage (' delay in for at least 1 month);
The Exit;
end;

F:=TIniFile. Create (ExtractFilePath (' D: \ APark \ APark adf));
SName:=f.R eadString (' Options' and 'LastUser', '0001');

Q:=TADOQuery. Create (Self);
Q.C onnectionString:='Provider=SQLOLEDB. 1; Password='+ b_sPassword +'; Persist Security Info=True; User ID=sa; Initial Catalog=APark; Data Source='+ b_sDBServer;
Q.S QL. Text:='select * from T1_Operator where mID=' + sName + ';
Q.O pen;
SName:=q.F ieldByName (' Name '). AsString;
Q.C lose;
Q.S QL. Text:=' ';

With qryBatch do
The begin
If the not Active then
The Open;
RowIndex:=0;
First;
While not Eof do
The begin
If cxGrid1DBTableView1. The codebehind (categories.aspx.cs). Records [rowIndex] Values [0]=null then
The Exit;
If cxGrid1DBTableView1. The codebehind (categories.aspx.cs). Records [rowIndex] Values [0]='1' then
The begin
Edit;
//t3 table modify the period of validity, t4 table insert a record
If FieldByName (' Expiry.) AsString="' then
FieldByName (' Expiry). AsDateTime:=Now;

SDate=FieldByName (' Expiry) AsString;
FieldByName (' Expiry). AsDateTime:=IncMonth (FieldByName (' Expiry). AsDateTime, StrToInt (edtTemp. Text));

Q.S QL. Add (' insert into t4_fee (mids, DateTime, FeeType ExtendStart, ExtendEnd, FeeIndeed, FeeShould, Operator) '+
'values (' + FieldByName (' mid) AsString +', getdate (), 3, cast (' + sDate + 'as a datetime) +'
', cast (' + FieldByName (' Expiry). AsString + 'as a datetime),' + eFeeTotal. Text + ', '+ eFeeTotal. Text +', ' '+ sName +' ' '));

Q.E xecSQL;
end;

If (cxGrid1DBTableView1. The codebehind (categories.aspx.cs). Records [rowIndex] Values [0]='0') or
(cxGrid1DBTableView1. The codebehind (categories.aspx.cs). Records [rowIndex] Values [0]='1') then
Next;

Inc (rowIndex);

If cxGrid1DBTableView1. DataController. IsEOF then
The Exit;

If cxGrid1DBTableView1. Controller. FocusedRow. IsLast then
The Exit;
end;
Edit;
UpdateBatch (arAll);
Q.D estroy;
end;
end;

CodePudding user response:

If (cxGrid1DBTableView1. The codebehind (categories.aspx.cs). Records [rowIndex] Values [0]='0') or
(cxGrid1DBTableView1. The codebehind (categories.aspx.cs). Records [rowIndex] Values [0]='1') then
Next;

Inc (rowIndex);

Every time is not necessarily performed qrybatch. Next; But rowindex + 1 at a time, in the QRY. EOF=TRUE, rowindex will cross!!!!!

CodePudding user response:

reference 1st floor n29882942 response:
if (cxGrid1DBTableView1. The codebehind (categories.aspx.cs). Records [rowIndex] Values [0]='0') or
(cxGrid1DBTableView1. The codebehind (categories.aspx.cs). Records [rowIndex] Values [0]='1') then
Next;

Inc (rowIndex);

Every time is not necessarily performed qrybatch. Next; But rowindex + 1 at a time, in the QRY. EOF=TRUE, rowindex will cross!!!!!


, so that will be more because of the need for group by group by the number of rows, not assignment can jump over it

CodePudding user response:

You have a data set loop structure problem
1, should make full use of the data set Eof judgment statements,
2, your statement is to tail, and continue to read the data error,
3, the Next execution should not join condition, this will lead to circulation of sync,
Try the following:
 procedure TfrmBatchExtend. SbtnExtendClick (Sender: TObject); 
Var
RowIndex: Integer;
Q: TADOQuery;
SDate, sName, s: a string;
F: TIniFile;
The begin
If (eExtend. Text='0') or (eExtend. Text=' ') then
The begin
ShowMessage (' delay in for at least 1 month);
The Exit;
end;

F:=TIniFile. Create (ExtractFilePath (' D: \ APark \ APark adf));
SName:=f.R eadString (' Options' and 'LastUser', '0001');

Q:=TADOQuery. Create (Self);
Q.C onnectionString:='Provider=SQLOLEDB. 1; Password='+ b_sPassword +'; Persist Security Info=True; User ID=sa; Initial Catalog=APark; Data Source='+ b_sDBServer;
Q.S QL. Text:='select * from T1_Operator where mID=' + sName + ';
Q.O pen;
SName:=q.F ieldByName (' Name '). AsString;
Q.C lose;
Q.S QL. Text:=' ';

With qryBatch do
The begin
If the not Active then
The Open;
RowIndex:=0;
First;
While not Eof do
The begin
Inc (rowIndex);
If cxGrid1DBTableView1. The codebehind (categories.aspx.cs). Records [rowIndex] Values [0]=null then
The Exit;
If cxGrid1DBTableView1. The codebehind (categories.aspx.cs). Records [rowIndex] Values [0]='1' then
The begin
Edit;
//t3 table modify the period of validity, t4 table insert a record
If FieldByName (' Expiry.) AsString="' then
FieldByName (' Expiry). AsDateTime:=Now;

SDate=FieldByName (' Expiry) AsString;
FieldByName (' Expiry). AsDateTime:=IncMonth (FieldByName (' Expiry). AsDateTime, StrToInt (edtTemp. Text));

Q.S QL. Add (' insert into t4_fee (mids, DateTime, FeeType ExtendStart, ExtendEnd, FeeIndeed, FeeShould, Operator) '+
'values (' + FieldByName (' mid) AsString +', getdate (), 3, cast (' + sDate + 'as a datetime) +'
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related