Click here to Skip to main content
15,905,233 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello everyone,
I am working on 1 healthcare project. In that project there is a provision to book an appointment of patient. For appointment booking, I am using a check box to select time slot. Now I want to show/enable checkboxes according to hour/time. Example: if right now time is 12pm so user should not able to book appointment of 10 am, she only able to book appointment after 12pm.

Can anyone give some idea what should I do??
Thanks in advance....
Posted
Comments
hsakarp 14-Nov-13 5:39am    
On page load you can check the current time and disable the corresponding text-box.
Thanks7872 14-Nov-13 5:43am    
How user is suppose to select timeslot? Have you provided predefined choices using checkbox?
♥…ЯҠ…♥ 14-Nov-13 5:57am    
So you have 24hrs(12am - 12pm) or total working 8 hours(9am - 5pm) checkboxes in your application?
betu.009 14-Nov-13 6:00am    
yes i have some predefined checkboxes in my web page
♥…ЯҠ…♥ 14-Nov-13 6:07am    
I started woriking on it, what is the naming convention you have used to name all the checkbox?

Hi Betu,

I tried your requirement that you can make use of it.
I have placed three checkbox in aspx page like this
ASP.NET
<asp:checkbox id="CheckBox1" runat="server" text="3 PM"/> <!--24Hr Text="15 PM"-->
<asp:checkbox id="CheckBox2" runat="server" text="4 PM"/> <!--24Hr Text="16 PM"-->
<asp:checkbox id="CheckBox3" runat="server" text="5 PM" /><!--24Hr Text="17 PM"-->

In server side, wrote a common validation function for checkbox
C#
protected void checkboxHoursValidate(CheckBox chkBox)
       {
           int hours = Convert.ToInt32(DateTime.Now.ToString("hh")); // 12Hr time format
           // int hours = DateTime.Now.Hour; // 24hr time format
           int chkbxHr = Convert.ToInt32(chkBox.Text.Split(' ')[0]);
           chkBox.Enabled = hours < chkbxHr;
       }

And in Page_Load method, am passing my required checkbox to the validation function like this
C#
checkboxHoursValidate(CheckBox1);
checkboxHoursValidate(CheckBox2);
checkboxHoursValidate(CheckBox3);

I checked at 4:45 PM IST, at that time it disables checkbox1(3 PM) and checkbox2(4 PM) respectively
Checkbox3(5 PM) alone is enabled.

Hope this gives you some idea how to make use of.

Regards,
RK
 
Share this answer
 
v3
Comments
betu.009 19-Nov-13 6:40am    
thanks a lot sir...its working
♥…ЯҠ…♥ 19-Nov-13 7:32am    
Glad...!!
Hi,


Add one field called Shift (AM/PM).

In database table add Shift along with Timing in master table.

While you display that timing just check

Where Now.ToString("tt")== DBValue.Shift

This is just hint you may use this logic to solve your issue.

---Chetan
 
Share this answer
 
I would define a Dictionary<CheckBox,int> that held the CheckBoxes corresponding to the time-slots for appointments as its Keys, and the offset from midnight to the beginning of the time-slot as its values:
C#
// code shown here is done in WinForms, but should map to ASP.NET easily

private Dictionary<CheckBox, int> dctCBxDTm;

// used to hold the current hour
private int currentHour;

private void YourApp_SomeInitializationEvent()
{
    // assume hourly appointments beginning at 8AM
    // an hour break for lunch, then 1PM ~ 4PM
    dctCBxDTm = new Dictionary<CheckBox, int>
    {
        {checkBox1, 8},
        {checkBox2, 9},
        {checkBox3, 10},
        {checkBox4, 11},
        {checkBox5, 13},
        {checkBox6, 14},
        {checkBox7, 15},
        {checkBox8, 16}
    };
}
Then I'd define a schedule update function:
C#
private void ScheduleUpdate()
{
    // get the current hour
    currentHour = DateTime.Now.Hour;

    // test if in working hours assume:
    // appointments can be scheduled
    // beginning 6am up to 3:59PM
    if (currentHour < 6 || currentHour > 16)
    {
        // use whatever to show a dialog
        MessageBox.Show("Thank you for using ACA HealthCare.\r\n\r\nTry again tomorrow if you are not dead.", "Morituri te Salutamus", MessageBoxButtons.OK, MessageBoxIcon.Warning);

        // exit
        return;
    }

    foreach (var kvp in dctCBxDTm)
    {
        kvp.Key.Enabled = kvp.Value >= currentHour;
    }
}
Obviously you need to determine how you want to call the update function, how frequently, etc. I'd do that "on demand" whenever a user of the system starts your site, after, I assume, a log-in process.
 
Share this answer
 
Hello betu.009,

Use the Observer pattern.

JAFC
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900