I have created a form and every time a DBdaysource creates an item in DBplanner i call the form to serve as an editor but the changes i create to the (Suppose to be) item editor form doesnt show on the planner.
but it does insert items in the database correctly but if i close the program and reopen it again the items doesnt reflect on the DBplanner. the planner remains empty.
pls help me.
Without knowing / seeing your code, it is hard to tell what could be wrong.
Did you have a look at demo 4 or demo 13 that shows the use of PlannerItem editors?
Here is some sample code where I having trouble with
@frmPlanner
procedure TfrmPlanner.DBDaySource1InsertItem(Sender: TObject;
APlannerItem: TPlannerItem);
begin
frmItemEditor:=TfrmItemEditor.Create(self);
frmItemEditor.dtpStartTime.DateTime:=APlannerItem.ItemStartTime;
frmItemEditor.dtpEndTime.DateTime:=APlannerItem.ItemEndTime;
frmItemEditor.strItemKey:=APlannerItem.dbKey;
frmItemEditor.editorConnString:=ADOTable1.ConnectionString;
frmItemEditor.Show;
DBDaySource1.SynchDBItems;
end;
@frmItemEditor
procedure TfrmItemEditor.btnAddClick(Sender: TObject);
var
queryAdd: TAdoQuery;
begin
queryAdd:=TADOQuery.Create(nil);
with queryAdd do
begin
ConnectionString:=editorConnString;
SQL.Clear;
SQL.Text:='INSERT INTO Waiting List '
+'Values (?,?,?,?,?,?)';
Parameters.Clear;
Parameters.CreateParameter('@date',ftString,pdInput,40,strItemKey);
Parameters.CreateParameter('@start',ftDateTime,pdInput,8,dtpStartTime.DateTime);
Parameters.CreateParameter('@end',ftDateTime,pdInput,8,dtpEndTime.DateTime);
Parameters.CreateParameter('@notes',ftString,pdInput,200,edtNotes.Text);
Parameters.CreateParameter('@subject',ftString,pdInput,100,edtSubject.Text);
Parameters.CreateParameter('@venue',ftString,pdInput,50,edtVenue.Text);
ExecSQL;
end;
queryAdd.Free;
Close;
end;
in these code you will see that the DBplanner is connected to a DBdaySource.
and in DBDaysource event InsertItem I called the form ItemEditor where in i created a Query to insert data in the database.
here is where the problem begins after i inserted the data and close the Editor form.and got back to the Planner form the item doesn't show the Subject and the Notes that i specified in the Editor form
in these code you will see that the DBplanner is connected to a DBdaySource.
and in DBDaysource event InsertItem I called the form ItemEditor where in i created a Query to insert data in the database.
here is where the problem begins after i inserted the data and close the Editor form.and got back to the Planner form the item doesn't show the Subject and the Notes that i specified in the Editor form
is there a way to refresh the dbdaysource or the planner to reflect the changes that happened it the database
This is not the correct way to create an item editor.
You should not do all these database manipulations from your editor or from code. The DBPlanner will create the item for you in the database to begin with.
Then create a class that descends from TCustomItemEditor and implement
TSampleItemEditor = class(TCustomItemEditor)
public
procedure CreateEditor(AOwner: TComponent); override;
procedure DestroyEditor; override;
function Execute: Integer; override;
procedure PlannerItemToEdit(APlannerItem: TPlannerItem); override;
procedure EditToPlannerItem(APlannerItem: TPlannerItem); override;
end;
1) procedure CreateEditor(AOwner: TComponent); override;
Create your form here
2) procedure DestroyEditor; override;
Destroy your form here
3) function Execute: Integer; override;
Show your form here
4) procedure PlannerItemToEdit(APlannerItem: TPlannerItem); override;
Populate edit controls on your form with the PlannerItem property settings
5) procedure EditToPlannerItem(APlannerItem: TPlannerItem); override;
Update the PlannerItem property settings with values from edit controls on the form
The use of the item editors is demonstrated in demo apps 4 & 13. Please have a look at it as well as PDF developers guide from page 29.
in number 3 what do you mean by a function that returns an integer?
what the integer stand for?
thank you for the big help i really appreciated the response thank you again
integer = modalresult of the form