Solved

Printing scheduled appointments in a predefined timegrid

Posted on 2006-11-12
8
286 Views
Last Modified: 2010-04-05
Hi,

In a database I store scheduled appointments. There are no overlapping appointments.
I want to print these appointments within a timegrid.

Database Appoitments:
START                  END                      DESCRIPTION
10-10-2006 09:45  10-10-2006 11:00  Appointment 1
10-10-2006 11:00  10-10-2006 12:00  Appointment 2

Printout on timegrid: Date 10-10-2006
09:00
09:15
09:30
09:45    09:45 - 11:00  Appointment 1
10:00
10:15
10:30
10:45
11:00    11:00 - 12:00  Appointment 2
11:15
etc. etc. etc.

I can't figure out how to do the following:
1. So the timegrid must be filled regardless of the number of appointments.
2. The appointments must be aligned within the grid based on the start date/time.

Additional problem: How to position a starttime that isn't matchable with a predefined time in the timegrid (f.e. 09:10).
09:00    09:10 - 09:45 Appointment 3

Thank you very much for your help in this.

Regards,
Stef
0
Comment
Question by:Delphiwizard
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
8 Comments
 
LVL 11

Assisted Solution

by:calinutz
calinutz earned 500 total points
ID: 17925032
First you must decide if you want a DBGrid or a StringGrid. It makes a difference
  For DBGrid... all you have to do is use a temporary table where you will insert the timegrid, and then update with the appointments. After that, the DBGrid will simply show the result

For StringGrid... almost the same... generate the stringGrid manually instead of working with a datasource, you will have to insert the timegrid like :
StringGrid.Cells[0,1]:='09:00'
...
The same goes fro the appointments... you would have to parse the cells for the needed hour and place there the appointment text.
So I would go for the DBGrid version
0
 
LVL 11

Accepted Solution

by:
calinutz earned 500 total points
ID: 17925059
so build your timegrid something like this:

var
 i:integer  ;
 t:TTime;
begin
t:=StrToTime('09:00');

actio.Active:=false;
actio.SQL.Clear;
actio.SQL.Add('delete from test_time');
actio.ExecSQL;

repeat
actio.Active:=false;
actio.SQL.Clear;
actio.SQL.Add('insert into test_time (times) values ('+QuotedStr(TimeToStr(t))+')');
actio.ExecSQL;
t:=IncMinute(t,15)
until t>=StrToTime('17:00');

AdoTable1.Active:=false;
AdoTable1.Active:=true;
end;


// where column times is of tipe smalldatetime
// also must set the field property of ADOTabel1 to the following display format:     HH:MM

0
 
LVL 11

Expert Comment

by:calinutz
ID: 17925062
For better understanding I will paste the dfm down here:
object Form1: TForm1
  Left = 192
  Top = 107
  Width = 554
  Height = 563
  Caption = 'Form1'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object Button1: TButton
    Left = 80
    Top = 68
    Width = 169
    Height = 25
    Caption = 'Generate timegrid'
    TabOrder = 0
    OnClick = Button1Click
  end
  object DBGrid1: TDBGrid
    Left = 80
    Top = 96
    Width = 457
    Height = 397
    DataSource = DataSource1
    TabOrder = 1
    TitleFont.Charset = DEFAULT_CHARSET
    TitleFont.Color = clWindowText
    TitleFont.Height = -11
    TitleFont.Name = 'MS Sans Serif'
    TitleFont.Style = []
  end
  object ADOConnection1: TADOConnection
    Connected = True
    ConnectionString =
      'Provider=SQLOLEDB.1;Password=yourpassword;Persist Security Info=' +
      'True;User ID=sa;Initial Catalog=yourDB;Data Source=SERVER'
    LoginPrompt = False
    Provider = 'SQLOLEDB.1'
    Left = 12
    Top = 12
  end
  object ADOTable1: TADOTable
    Active = True
    Connection = ADOConnection1
    CursorType = ctStatic
    TableName = 'test_time'
    Left = 92
    Top = 12
    object ADOTable1times: TDateTimeField
      FieldName = 'times'
      DisplayFormat = 'HH:MM'
    end
    object ADOTable1tesxt: TWideStringField
      FieldName = 'tesxt'
      Size = 50
    end
  end
  object DataSource1: TDataSource
    DataSet = ADOTable1
    Left = 132
    Top = 12
  end
  object actio: TADOQuery
    Connection = ADOConnection1
    Parameters = <>
    Left = 16
    Top = 64
  end
end
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 11

Assisted Solution

by:calinutz
calinutz earned 500 total points
ID: 17925071
Of course you must enter your info about user name, password and host of the server.
Naturaly you can do the same different database approach, other DB Engine, TCustomDataset, Access DB, or whatever.
I just gave you an example on how it can be made.


And about adding an hour that starts at another point that does not exist in the timegrid... just do the insert of the respective appointment in the table, and then sort the table by the times field... create an index on that field and all will be alright. the appointment will appear in the grid between the times that are smaller and bigger than it.


regards
0
 

Author Comment

by:Delphiwizard
ID: 17925120
Thank you Calinutz,

But an important part of my question isn't answered yet:
*************
2. The appointments must be aligned within the grid based on the start date/time.

Additional problem: How to position a starttime that isn't matchable with a predefined time in the timegrid (f.e. 09:10).
09:00    09:10 - 09:45 Appointment 3
*************
0
 

Author Comment

by:Delphiwizard
ID: 17925146
When I would just insert the appointments into the table there will be duplicate starttimes in the table.

Like:
09:45
09:45    09:45 - 11:00  Appointment 1

0
 
LVL 11

Assisted Solution

by:calinutz
calinutz earned 500 total points
ID: 17928714
You probabely missunderstood  what I sayd.
After you generate the timegrid by inserting in the table the standard hours: 09:00, 09:15, 09:30... etc
if you have an apointment at a predefined date like the standard ones... you will do an update on the table... (so not an insert),
and

- if you have an appointment that cannot be found in the timegrid (so it's not standard 09:15, 09:30 etc) suppose it's 09:23,
in this case you just do an insert in the table.

Any Query like:
select * from test_time order by times
will order your appointments in order of the time... so what's the problem?
0
 

Author Comment

by:Delphiwizard
ID: 17928898
I understand now what you mean.
Thank you for your help.

Regards,
Stef
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses
Course of the Month9 days, 23 hours left to enroll

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question