Solved

Printing scheduled appointments in a predefined timegrid

Posted on 2006-11-12
8
273 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
  • 5
  • 3
8 Comments
 
LVL 11

Assisted Solution

by:calinutz
calinutz earned 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 11

Assisted Solution

by:calinutz
calinutz earned 500 total points
Comment Utility
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

Author Comment

by:Delphiwizard
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
I understand now what you mean.
Thank you for your help.

Regards,
Stef
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now