CGDevTools Forum

Welcome to the Official CGDevTools Support Community Forums.

Scheduler connect to database

Questions & Answers about IWCGJQuery Suite.

by zsleo » 18 Dec 2015 07:14

Hi,

Yes! Scheduler has a big/steep learning curve.

Here is a code snippet that may help you - I struggled with it for a long time but it is quite powerful.
Code: Select all
  Scheduler.JQSchedulerOptions.StartHour := lv_Start - 1;
  Scheduler.JQSchedulerOptions.EndHour := lv_End + 1;

  while not qry1.Eof do
  begin
    currItem := Scheduler.JQSchedulerOptions.EventItems.Add;
    currItem.StartTime := qry1.FieldByName('StartTime').AsDateTime;
    currItem.EndTime := IncMinute(currItem.StartTime, qry1.FieldByName('Duration').AsInteger);
    currItem.Editable := (not qry1.FieldByName('DoNotBook').AsBoolean) { }
      and (qry1.FieldByName('Editable').AsBoolean) and (currItem.EndTime > Now);

    if qry1.FieldByName('PersonName').AsString > '' then
      currItem.EventTitle := qry1.FieldByName('AppointmentFor').AsString + ' for ' + qry1.FieldByName('PersonName').AsString
    else
      currItem.EventTitle := qry1.FieldByName('AppointmentFor').AsString;

    if qry1.FieldByName('DoNotBook').AsBoolean then
    begin
      currItem.EventContent := qry1.FieldByName('Notes').AsString;
      currItem.EventHint := 'Do Not Book - ' + currItem.EventTitle + ': ' + currItem.EventContent;
    end
    else if qry1.FieldByName('PersonNumber').AsInteger > 0 then
    begin
      if qry1.FieldByName('Status').AsString = 'D' then
        lv_HintHdr := 'Did NOT Attend'
      else if qry1.FieldByName('Status').AsString = 'E' then
        lv_HintHdr := 'Not Billed'
      else if qry1.FieldByName('Status').AsString = 'C' then
        lv_HintHdr := 'In Meeting'
      else if qry1.FieldByName('Status').AsString = 'F' then
      begin
        if qry1.FieldByName('Status_2').AsString = 'B' then
          lv_HintHdr := 'Billed'
        else
          lv_HintHdr := 'Completed';
      end
      else if qry1.FieldByName('Status').AsString = 'W' then
        lv_HintHdr := 'Waiting Bill'
      else
        lv_HintHdr := 'Arrived';

      currItem.EventHint := lv_HintHdr + ' - ' + currItem.EventTitle + ': ' + currItem.EventContent;
      currItem.EventContent := qry1.FieldByName('Notes').AsString;

    end
    else if currItem.EndTime < Now then
    begin
      currItem.EventContent := qry1.FieldByName('Notes').AsString;
      if qry1.FieldByName('PersonName').AsString = '' then
        lv_HintHdr := 'Past'
      else if currItem.EndTime < Date then
        lv_HintHdr := 'Did NOT Attend'
      else if not qry1.FieldByName('Arrived').IsNull and (qry1.FieldByName('Arrived').AsDateTime > 1000) then
        lv_HintHdr := 'Not Arrived';

      currItem.EventHint := lv_HintHdr + ' - ' + currItem.EventTitle + ': ' + currItem.EventContent;
      currItem.EventContent := qry1.FieldByName('Notes').AsString;
    end
    else if qry1.FieldByName('PersonName').AsString = '' then
    begin
      currItem.EventHint := 'Open';
      currItem.EventContent := '';
    end
    else
    begin
      currItem.EventContent := qry1.FieldByName('Notes').AsString;
      currItem.EventHint := 'Booked - ' + currItem.EventTitle + ': ' + currItem.EventContent;
    end;

    currItem.ID := qry1.FieldByName('AppointmentID').AsInteger;
    currItem.AllDay := qry1.FieldByName('AllDay').AsBoolean;
    currItem.CrossDay := qry1.FieldByName('CrossDay').AsBoolean;

    currItem.Location := qry1.FieldByName('Building').AsString + '/' + qry1.FieldByName('Room').AsString;
    currItem.Subject := qry1.FieldByName('AppointmentFor').AsString;
    qry1.Next;
  end;

  Scheduler.Update;


By no means complete but I hope it helps

Have fun
zsleo
 
Posts: 776
Joined: 03 Feb 2013 03:33

by MarkLince » 18 Dec 2015 10:27

Hi zsleo,
Thanks for the help and the code very generous of you. If I might ask, how do you manage the default behaviour of the scheduler as it is creating event items when you click on a cell with the dialog box popping up.

I'm trying to stop this behaviour without making the scheduler readonly. There seems to be no mechanism I can see for the user to choose whether they want to create an event or not (other than dealing with the popup dialog). Its a bit old having the dialog box popup everytime you click a cell and having to cancel it all the time.

Have a quick scan at my previous posts in this thread. (I know I've gone off my own topic a bit).

Thanks again for your help.
Regards
Mark
MarkLince
 
Posts: 20
Joined: 16 Dec 2015 02:19

by assapan » 18 Dec 2015 10:47

Hi Mark,
You have in JQSchedulerOptions 4 event you can trap
    Add
    Edit
    Delete
so for all of these events you van react or not depending of the context without showing the dialog
Want to visit Ardeche http://leclosdelarc.fr/index.php
The Pont d’Arc Cavern http://en.cavernedupontdarc.fr
Image
User avatar
assapan
 
Posts: 600
Joined: 16 Dec 2013 12:04
Location: France

by assapan » 18 Dec 2015 10:52

Have a look to this video http://assapan.fr/Reservation.mp4
Want to visit Ardeche http://leclosdelarc.fr/index.php
The Pont d’Arc Cavern http://en.cavernedupontdarc.fr
Image
User avatar
assapan
 
Posts: 600
Joined: 16 Dec 2013 12:04
Location: France

by Jorge Sousa » 18 Dec 2015 11:25

Hi Mark

About

Sorry to disagree, but I don't think making the calendar readonly is the same as what I'm proposing which is being able to control when individual event items are selected, created and or edited. I don't want the control to be not editable I just would like to be able to choose when and how each event item is created/ edited. It would seem at the moment that this is an all or nothing arrangement.


I know that readonly is very different from what you're proposing, only i didn't see that property before.

Now, about the changes you suggest: If I understand correctly, you want to be able to track click events, inside an event box or not, to be able to trigger the creation / edition programatically, is this correct?

t.i.a.
Best Regards
CGDevTools Develop / Support Team
Home Page: http://www.cgdevtools.com
Jorge Sousa
 
Posts: 4261
Joined: 17 May 2012 09:58

by MarkLince » 18 Dec 2015 21:27

Hi,
Thanks again everyone for the help. Thanks asspan for the video.

Jorge Sousa wrote:I know that readonly is very different from what you're proposing, only i didn't see that property before.


My apologies, I misunderstood what you meant.

.
Jorge Sousa wrote:Now, about the changes you suggest: If I understand correctly, you want to be able to track click events, inside an event box or not, to be able to trigger the creation / edition programatically, is this correct?


Essentially yes! To be able to select an empty cell or any event item (maybe have it highlighted) and to be able to choose programmatically whether to create a new event or edit an existing one. So essentially the user would be able to click anywhere on the grid and no event creation is triggered unless proposed OnEventClick or OnDblEventClick is programmatically set.

Also just purchased full source licence, can't wait to start using it proper!

Thanks again peoples
Regards
Mark
MarkLince
 
Posts: 20
Joined: 16 Dec 2015 02:19

by zsleo » 19 Dec 2015 07:41

MarkLince wrote:Thanks for the help and the code...


A pleasure.

I have not found a solution to stopping the popup - but I'd like to have that control at the item level.
zsleo
 
Posts: 776
Joined: 03 Feb 2013 03:33

by MarkLince » 20 Dec 2015 18:01

As this has gone off original topic (my fault), but its still really quite important to me I will be starting a new thread topic

Scheduler Event Item Edit and Creation Control http://www.cgdevtools.com/cgforum/viewtopic.php?f=8&t=2628
Mark
MarkLince
 
Posts: 20
Joined: 16 Dec 2015 02:19

Previous

Return to Q & A

Who is online

Users browsing this forum: No registered users and 3 guests

Contact Us.