Home > Back-end >  Dbgrid data entry on the next line???
Dbgrid data entry on the next line???

Time:09-28

I need to give students entry, is fixed with an edit input, I now need a feature, for example, I begin from the first student entry, just after the first input in the edit, press enter to submit grades, and jump to the second student, and focus on edit, enter again, under one of the students of the input, and so on, now can only solve the manual entry of a person's achievement, cannot solve the automatic jump, first above

 with qry2 do 
The begin
The Close;
SQL. The Clear;
SQL. The Add (+ cbb7 'update'. The 'set' Text + + dbgrdh2. Columns [cbb7. ItemIndex + 1] '=' FieldName + + trim (rzedit2. Text) + 'where s_name=' "+ trim (rzedit1. Text) +" '");
//Parameters. ParamByName (dbgrdh2. Columns [cbb7. ItemIndex + 1] FieldName). The Value:=trim (rzedit2. Text);
ExecSQL;
//update test set ldt_score='2.19' where s_name='Fan Zheming' this code in the query parser implementation success
RzButton1. Click;
Rzedit2. Text:=' ';


Your good friend, help me!!!!!!!!!!!

CodePudding user response:

With a dataset do
The begin
post;
next;
If eof then
last;
Edit. Setfocus;
end;

More than just thinking

CodePudding user response:

1, the use of SQL statements to update data bank,
2, after the update, through Next to the Next line,
Repeat 1 and 2, 3

CodePudding user response:



Reference code:
 
Procedure TForm1. Edit1KeyDown (Sender: TObject; Var Key Word;
Shift: TShiftState);
The begin
If (Key=13) then
The begin
With ADOQuery2 do
The begin
The close;
SQL. Text:='select * from DrawLine where lineid=' + edit2. Text + ';
The Open;

Edit;
FieldByName (' LinePenColor). AsInteger:=StrToInt (edit1. Text);
Post;
end;

If ADOQuery1. RecNo=ADOQuery1. RecordCount then
The begin
//ShowMessage (' last line);
End
The else
The begin
ADOQuery1. RecNo:=ADOQuery1. RecNo + 1;
Edit1. Text:=DBGrid1. The DataSource. The DataSet. FieldByName (' LinePenColor). AsString;
Edit2. Text:=DBGrid1. The DataSource. The DataSet. FieldByName (" LineID "). The AsString;
The end;

//ADOQuery1. DisableControls;
//ADOQuery1. Refresh;
//ADOQuery1. EnableControls;

Edit1. SetFocus;
Edit1. SelectAll;
ADOQuery1. Refresh;
end;
end;

CodePudding user response:

SQL statements to update data bank, and then next

CodePudding user response:

reference 4 floor u011840021 response:
SQL statements to update data bank, and then next


It's as simple as that,

CodePudding user response:

reference yct0605 reply: 3/f


Reference code:
 
Procedure TForm1. Edit1KeyDown (Sender: TObject; Var Key Word;
Shift: TShiftState);
The begin
If (Key=13) then
The begin
With ADOQuery2 do
The begin
The close;
SQL. Text:='select * from DrawLine where lineid=' + edit2. Text + ';
The Open;

Edit;
FieldByName (' LinePenColor). AsInteger:=StrToInt (edit1. Text);
Post;
end;

If ADOQuery1. RecNo=ADOQuery1. RecordCount then
The begin
//ShowMessage (' last line);
End
The else
The begin
ADOQuery1. RecNo:=ADOQuery1. RecNo + 1;
Edit1. Text:=DBGrid1. The DataSource. The DataSet. FieldByName (' LinePenColor). AsString;
Edit2. Text:=DBGrid1. The DataSource. The DataSet. FieldByName (" LineID "). The AsString;
end;

//ADOQuery1. DisableControls;
//ADOQuery1. Refresh;
//ADOQuery1. EnableControls;

Edit1. SetFocus;
Edit1. SelectAll;
ADOQuery1. Refresh;
end;
end;

Is this meaning, very good!

CodePudding user response:

ADOQuery1 associated with dbgrid components, ADOQuery2 used to update the data,
  • Related