Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Printing scheduled appointments in a predefined timegrid

Posted on 2006-11-12
8
Medium Priority
?
289 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:Stef Merlijn
  • 5
  • 3
8 Comments
 
LVL 11

Assisted Solution

by:calinutz
calinutz earned 2000 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 2000 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 11

Assisted Solution

by:calinutz
calinutz earned 2000 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:Stef Merlijn
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:Stef Merlijn
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 2000 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:Stef Merlijn
ID: 17928898
I understand now what you mean.
Thank you for your help.

Regards,
Stef
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

971 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