Ensure we display a message dialog when the user tries an UPDATE, DELETE or INSERT in datagrid and he is not allowed to do that. Could be there are more places like this, f.x. when saving table structure.

This commit is contained in:
Ansgar Becker
2009-11-06 00:04:26 +00:00
parent 0a53443524
commit 362a9fe1fe

View File

@ -6969,8 +6969,11 @@ begin
end;
Result := True;
except
on E:Exception do begin
MessageDlg(E.Message, mtError, [mbOK], 0);
Result := False;
end;
end;
if Result then begin
// Reselect just updated row in grid from server to ensure displaying
@ -7173,6 +7176,7 @@ begin
Cols := Copy(Cols, 1, Length(Cols)-2);
sql := 'INSERT INTO '+mask(DataGridDB)+'.'+mask(DataGridTable)+' ('+Cols+') VALUES ('+Vals+')';
// Send INSERT query
try
Connection.Query(sql);
if Connection.RowsAffected = 0 then
MessageBox(Self.Handle, 'Server failed to insert row.', 'Error', 0);
@ -7180,6 +7184,12 @@ begin
Row.Loaded := false;
EnsureNodeLoaded(Sender, Node, GetWhereClause(Row, @DataGridResult.Columns));
GridFinalizeEditing(Sender);
except
on E:Exception do begin
MessageDlg(E.Message, mtError, [mbOK], 0);
Result := False;
end;
end;
end;
end;
@ -7212,8 +7222,11 @@ begin
Connection.Query(sql);
Result := True;
except
on E:Exception do begin
MessageDlg(E.Message, mtError, [mbOK], 0);
Result := False;
end;
end;
if Result then begin
// Remove deleted row nodes out of the grid