date time picker weekly

G

Guest

Visual C# 2005 Express -
I am creating a employee scheduling program for work.

When I need to do is for the program to open with a start date of the
previous sunday. I also want the ability to change the start date to create a
new schedule - however, it must begin on a sunday. I want the sunday date to
be locked in so it doesn't always show the current date when executed. Also
for a prompt to appear if the user tries to use another day other than sunday.

I will also have daily headers for each column with the day and date listed.
Can I just use the datetimepicker value and add "1" to each column?

Thank you,
Greg Malenky
 
O

Otis Mukinfus

Visual C# 2005 Express -
I am creating a employee scheduling program for work.

When I need to do is for the program to open with a start date of the
previous sunday. I also want the ability to change the start date to create a
new schedule - however, it must begin on a sunday. I want the sunday date to
be locked in so it doesn't always show the current date when executed. Also
for a prompt to appear if the user tries to use another day other than sunday.

I will also have daily headers for each column with the day and date listed.
Can I just use the datetimepicker value and add "1" to each column?

Thank you,
Greg Malenky

private void MainForm_Load(object sender, System.EventArgs e)
{
// get the day of the week
int weekDay = (int)DateTime.Now.DayOfWeek;

// Subtracting the week day from the current day yields zero
// (the previous Sunday)
DateTime sunday = DateTime.Now.AddDays(weekDay * -1);

//Set the DateTimePicker's date to the result
dateTimePickerSunday.Value = sunday;
}

Does that do what you want?


Otis Mukinfus
http://www.otismukinfus.com
 
S

Sean Hederman

gregmalenky said:
Visual C# 2005 Express -
I am creating a employee scheduling program for work.

When I need to do is for the program to open with a start date of the
previous sunday. I also want the ability to change the start date to
create a
new schedule - however, it must begin on a sunday. I want the sunday date
to
be locked in so it doesn't always show the current date when executed.
Also
for a prompt to appear if the user tries to use another day other than
sunday.

I will also have daily headers for each column with the day and date
listed.
Can I just use the datetimepicker value and add "1" to each column?

Dunno if this'll help:
http://www.codingsanity.com/planner.htm

It's more designed for having the days as rows and hours as columns though.
 
G

Guest

Otis,

close to what I need - however, I want the program to open showing the
previous sunday's date (not when the datetimepicker is changed). Also, I need
the program to allow a user to change the date to the following (or future)
sundays. If sunday is not chosen, then a msgbox appears "you must start the
week on sunday"

Thanks,
Greg
 
O

Otis Mukinfus

On Fri, 8 Jul 2005 11:42:02 -0700, "gregmalenky"

See below
Otis,

close to what I need - however, I want the program to open showing the
previous sunday's date (not when the datetimepicker is changed). Also, I need
the program to allow a user to change the date to the following (or future)
sundays. If sunday is not chosen, then a msgbox appears "you must start the
week on sunday"

Thanks,
Greg

Interesting. I thought the example I gave you set the datetime picker to the
previous Sunday and since it's in the FormLoad event it sets the dtp when the
program loads. I think that's two of your requirements. The rest is up to you.
;o)

You didn't test the code or you would have seen the result you wanted.

See below...
Load event occurs when the program is opened
Otis Mukinfus
http://www.otismukinfus.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top